Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qdbusunixfiledescriptor.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
6
7#ifdef Q_OS_UNIX
8# include <private/qcore_unix_p.h>
9#endif
10
12
13#ifndef QT_NO_DBUS
14
16
17
91
92template<> inline
94{ if (d && !d->ref.deref()) delete d; }
95
107
127
135
142{
143 if (this != &other)
144 d.operator=(other.d);
145 return *this;
146}
147
160
176{
177 return d ? d->fd.loadRelaxed() != -1 : false;
178}
179
194{
195 return d ? d->fd.loadRelaxed() : -1;
196}
197
198// actual implementation
199#ifdef Q_OS_UNIX
200
201// qdoc documentation is generated on Unix
202
214{
215 return true;
216}
217
231void QDBusUnixFileDescriptor::setFileDescriptor(int fileDescriptor)
232{
233 if (fileDescriptor != -1)
235}
236
243void QDBusUnixFileDescriptor::giveFileDescriptor(int fileDescriptor)
244{
245 // if we are the sole ref, d remains unchanged
246 // if detaching happens, d->fd will be -1
247 if (d)
248 d.detach();
249 else
251
252 const int fdl = d->fd.loadRelaxed();
253 if (fdl != -1)
254 qt_safe_close(fdl);
255
256 if (fileDescriptor != -1)
258}
259
269{
270 if (!d)
271 return -1;
272
273 return d->fd.fetchAndStoreRelaxed(-1);
274}
275
277{
278 const int fdl = fd.loadRelaxed();
279 if (fdl != -1)
280 qt_safe_close(fdl);
281}
282
283#else
285{
286 return false;
287}
288
292
296
298{
299 return -1;
300}
301
305
306#endif
307
308#endif // QT_NO_DBUS
309
\inmodule QtCore
Definition qatomic.h:112
void storeRelaxed(T newValue) noexcept
T fetchAndStoreRelaxed(T newValue) noexcept
T loadRelaxed() const noexcept
\variable QDBusUnixFileDescriptor::d
QDBusUnixFileDescriptorPrivate(const QDBusUnixFileDescriptorPrivate &other)
int fileDescriptor() const
Returns the Unix file descriptor contained by this QDBusUnixFileDescriptor object.
bool isValid() const
Returns true if this Unix file descriptor is valid.
QDBusUnixFileDescriptor()
Constructs a QDBusUnixFileDescriptor without a wrapped file descriptor.
void setFileDescriptor(int fileDescriptor)
QDBusUnixFileDescriptor & operator=(QDBusUnixFileDescriptor &&other) noexcept
Move-assigns other to this QDBusUnixFileDescriptor.
~QDBusUnixFileDescriptor()
Destroys this QDBusUnixFileDescriptor object and disposes of the Unix file descriptor that it contain...
void giveFileDescriptor(int fileDescriptor)
void detach()
If the shared data object's reference count is greater than 1, this function creates a deep copy of t...
~QExplicitlySharedDataPointer()
Decrements the reference count of the shared data object.
\inmodule QtCore
Definition qshareddata.h:19
Combined button and popup list for selecting options.
static int qt_safe_dup(int oldfd, int atleast=0, int flags=FD_CLOEXEC)
static int qt_safe_close(int fd)
#define QT_IMPL_METATYPE_EXTERN(TYPE)
Definition qmetatype.h:1390
GLuint64 GLenum GLint fd
QObject::connect nullptr
QSharedPointer< T > other(t)
[5]