From c14103be50529f3d00cf1ecadafc0f8156ba7680 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 18 Oct 2018 15:30:14 +0200 Subject: Update dbus header and document its provenance There's been one minor change in a struct and some minor re-ordering of other things within their files (reflected here to simplify future checks); and qt_attribution.json didn't document enough details to ensure reliable review. Task-number: QTBUG-70011 Change-Id: Iccff9cfd899e58cb42837c4628acacd7877c5b01 Reviewed-by: Volker Hilsheimer --- src/dbus/dbus_minimal_p.h | 7 ++++--- src/dbus/qt_attribution.json | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src/dbus') diff --git a/src/dbus/dbus_minimal_p.h b/src/dbus/dbus_minimal_p.h index b52b0153e4..869c02b59d 100644 --- a/src/dbus/dbus_minimal_p.h +++ b/src/dbus/dbus_minimal_p.h @@ -218,7 +218,7 @@ struct DBusMessageIter int dummy10; /**< Don't use this */ int dummy11; /**< Don't use this */ int pad1; /**< Don't use this */ - int pad2; /**< Don't use this */ + void *pad2; /**< Don't use this */ /* Was int; changed to void* at 1.10.8 */ void *pad3; /**< Don't use this */ }; @@ -251,6 +251,7 @@ struct DBusMessageIter #define DBUS_TYPE_SIGNATURE_AS_STRING "g" #define DBUS_TYPE_UNIX_FD ((int) 'h') #define DBUS_TYPE_UNIX_FD_AS_STRING "h" + #define DBUS_TYPE_ARRAY ((int) 'a') #define DBUS_TYPE_ARRAY_AS_STRING "a" #define DBUS_TYPE_VARIANT ((int) 'v') @@ -270,14 +271,14 @@ struct DBusMessageIter #define DBUS_DICT_ENTRY_END_CHAR ((int) '}') #define DBUS_DICT_ENTRY_END_CHAR_AS_STRING "}" +#define DBUS_MAXIMUM_NAME_LENGTH 255 + #define DBUS_MESSAGE_TYPE_INVALID 0 #define DBUS_MESSAGE_TYPE_METHOD_CALL 1 #define DBUS_MESSAGE_TYPE_METHOD_RETURN 2 #define DBUS_MESSAGE_TYPE_ERROR 3 #define DBUS_MESSAGE_TYPE_SIGNAL 4 -#define DBUS_MAXIMUM_NAME_LENGTH 255 - #define DBUS_INTROSPECT_1_0_XML_NAMESPACE "http://www.freedesktop.org/standards/dbus" #define DBUS_INTROSPECT_1_0_XML_PUBLIC_IDENTIFIER "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" #define DBUS_INTROSPECT_1_0_XML_SYSTEM_IDENTIFIER "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd" diff --git a/src/dbus/qt_attribution.json b/src/dbus/qt_attribution.json index 52636ba89b..69d946ba5c 100644 --- a/src/dbus/qt_attribution.json +++ b/src/dbus/qt_attribution.json @@ -6,9 +6,12 @@ "Description": "D-Bus is a message bus system, a simple way for applications to talk to one another.", "Homepage": "https://www.freedesktop.org/wiki/Software/dbus/", + "Version": "Minimal supported is 1.2, compatible up to ...", + "Version": "1.12", "LicenseId": "AFL-2.1 OR GPL-2.0-or-later", "License": "Academic Free License v2.1, or GNU General Public License v2.0 or later", "LicenseFile": "LIBDBUS-1-LICENSE.txt", + "Files": "Fragments from various upstream files, see comments in ...", "Files": "dbus_minimal_p.h", "Copyright": "Copyright (C) 2002, 2003 CodeFactory AB Copyright (C) 2004, 2005 Red Hat, Inc." -- cgit v1.2.3 From 102a919b734440df85617f1e3a8ba43c612839d5 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Mon, 29 Oct 2018 18:32:04 +0100 Subject: Generate documentation .tags files for all of the docs This allows others to link to QtDBus and the other libraries/tools using doxygen. Fixes: QTBUG-60933 Change-Id: I026895a432a328f224c40cf231ad12d109dc648f Reviewed-by: Paul Wicking Reviewed-by: Venugopal Shivashankar Reviewed-by: Martin Smith --- src/dbus/doc/qtdbus.qdocconf | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/dbus') diff --git a/src/dbus/doc/qtdbus.qdocconf b/src/dbus/doc/qtdbus.qdocconf index 69eaa0eec3..4ff7242b25 100644 --- a/src/dbus/doc/qtdbus.qdocconf +++ b/src/dbus/doc/qtdbus.qdocconf @@ -21,6 +21,8 @@ excludedirs += ../../../examples/widgets/doc examplesinstallpath = dbus +tagfile = qtdbus.tags + depends += qtdoc qtcore # The following parameters are for creating a qhp file, the qhelpgenerator -- cgit v1.2.3 From 81d8319276f26d399bdff47b49bd69b19bd86c5a Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 10 Oct 2018 15:54:07 +0200 Subject: doc: Fix all clang parse errors in QtBase during PCH build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This update eliminates ALL parsing errors when clang parses the Qt headers to build the precompiled header qdoc needs. These errors are often cases where an old use of Q_QDOC no longer works because clang sees the enclosed fake declarations as erroneous. In a few cases, clang reported errors because two dummy function declartations under the Q_CLANG_QDOC guard were indistinguishable, so one of them was removed, and the documentation was patched accordingly. Using the macro Q_DECLARE_INTERFACE(...) causes clang to report errors because the class parametewr is abstract. These uses of the macro are not needed, so they are removed with #ifndef Q_CLANG_QDOC. Some declarations of default GL types that had been provided for qdoc were no longer needed, so they are removed. Now there are some member function signatures in QDBusPendingReply and QDBusPendingCall that have very long template clauses and qualifiers in their signatures. These unwieldy signatures will be unnecessary in the documentation and will look bad there, but for now they are correct. The ultimate solution will be to add a metacommand to qdoc, something like \simplify-signature to tell qdoc to generate the documentation for these member functions without the long template caluses and qualifiers. Change-Id: I012cf17a544fbba2ebc71002f31bdc865119bb8e Reviewed-by: Paul Wicking Reviewed-by: Topi Reiniƶ Reviewed-by: Martin Smith --- src/dbus/qdbusargument.cpp | 2 +- src/dbus/qdbusargument.h | 12 ++---------- src/dbus/qdbusconnection.h | 2 -- src/dbus/qdbuspendingcall.cpp | 12 ++++++------ src/dbus/qdbuspendingcall.h | 2 +- src/dbus/qdbuspendingreply.cpp | 29 ++++++++++++----------------- src/dbus/qdbuspendingreply.h | 3 --- src/dbus/qdbusreply.cpp | 2 +- src/dbus/qdbusreply.h | 4 ---- src/dbus/qdbusutil.cpp | 30 +++++++++++++++--------------- 10 files changed, 38 insertions(+), 60 deletions(-) (limited to 'src/dbus') diff --git a/src/dbus/qdbusargument.cpp b/src/dbus/qdbusargument.cpp index a33c4f8363..2d1373006d 100644 --- a/src/dbus/qdbusargument.cpp +++ b/src/dbus/qdbusargument.cpp @@ -267,7 +267,7 @@ bool QDBusArgumentPrivate::checkReadAndDetach(QDBusArgumentPrivate *&d) */ /*! - \fn qdbus_cast(const QDBusArgument &arg) + \fn template T qdbus_cast(const QDBusArgument &arg, T*) \relates QDBusArgument \since 4.2 diff --git a/src/dbus/qdbusargument.h b/src/dbus/qdbusargument.h index a6d4e9cd25..ac650d5f62 100644 --- a/src/dbus/qdbusargument.h +++ b/src/dbus/qdbusargument.h @@ -158,22 +158,14 @@ QT_END_NAMESPACE Q_DECLARE_METATYPE(QDBusArgument) QT_BEGIN_NAMESPACE -template inline T qdbus_cast(const QDBusArgument &arg -#ifndef Q_QDOC -, T * = nullptr -#endif - ) +template inline T qdbus_cast(const QDBusArgument &arg, T * = nullptr) { T item; arg >> item; return item; } -template inline T qdbus_cast(const QVariant &v -#ifndef Q_QDOC -, T * = nullptr -#endif - ) +template inline T qdbus_cast(const QVariant &v, T * = nullptr) { int id = v.userType(); if (id == qMetaTypeId()) diff --git a/src/dbus/qdbusconnection.h b/src/dbus/qdbusconnection.h index ca7adfaaeb..3711981f78 100644 --- a/src/dbus/qdbusconnection.h +++ b/src/dbus/qdbusconnection.h @@ -122,9 +122,7 @@ public: SubPath = 0x1 // Reserved = 0xff000000 }; -#ifndef Q_QDOC Q_DECLARE_FLAGS(VirtualObjectRegisterOptions, VirtualObjectRegisterOption) -#endif enum ConnectionCapability { UnixFileDescriptorPassing = 0x0001 diff --git a/src/dbus/qdbuspendingcall.cpp b/src/dbus/qdbuspendingcall.cpp index 2a31dd950a..4d0131afff 100644 --- a/src/dbus/qdbuspendingcall.cpp +++ b/src/dbus/qdbuspendingcall.cpp @@ -311,7 +311,7 @@ QDBusPendingCall &QDBusPendingCall::operator=(const QDBusPendingCall &other) \sa QDBusPendingReply::isFinished() */ /*! - \fn bool QDBusPendingReply::isFinished() const + \fn template bool QDBusPendingReply::isFinished() const Returns \c true if the pending call has finished processing and the reply has been received. If this function returns \c true, the @@ -340,7 +340,7 @@ void QDBusPendingCall::waitForFinished() } /*! - \fn bool QDBusPendingReply::isValid() const + \fn template bool QDBusPendingReply::isValid() const Returns \c true if the reply contains a normal reply message, false if it contains anything else. @@ -357,7 +357,7 @@ bool QDBusPendingCall::isValid() const } /*! - \fn bool QDBusPendingReply::isError() const + \fn template bool QDBusPendingReply::isError() const Returns \c true if the reply contains an error message, false if it contains a normal method reply. @@ -374,7 +374,7 @@ bool QDBusPendingCall::isError() const } /*! - \fn QDBusError QDBusPendingReply::error() const + \fn template QDBusError QDBusPendingReply::error() const Retrieves the error content of the reply message, if it has finished processing. If the reply message has not finished @@ -395,7 +395,7 @@ QDBusError QDBusPendingCall::error() const } /*! - \fn QDBusMessage QDBusPendingReply::reply() const + \fn template QDBusMessage QDBusPendingReply::reply() const Retrieves the reply message received for the asynchronous call that was sent, if it has finished processing. If the pending call @@ -445,7 +445,7 @@ bool QDBusPendingCall::setReplyCallback(QObject *target, const char *member) \since 4.6 Creates a QDBusPendingCall object based on the error condition \a error. The resulting pending call object will be in the - "finished" state and QDBusPendingReply::isError() will return true. + "finished" state and QDBusPendingReply::isError() will return true. \sa fromCompletedCall() */ diff --git a/src/dbus/qdbuspendingcall.h b/src/dbus/qdbuspendingcall.h index ec8ba6c541..24b1d6a7ca 100644 --- a/src/dbus/qdbuspendingcall.h +++ b/src/dbus/qdbuspendingcall.h @@ -67,7 +67,7 @@ public: void swap(QDBusPendingCall &other) Q_DECL_NOTHROW { qSwap(d, other.d); } -#ifndef Q_QDOC +#ifndef Q_CLANG_QDOC // pretend that they aren't here bool isFinished() const; void waitForFinished(); diff --git a/src/dbus/qdbuspendingreply.cpp b/src/dbus/qdbuspendingreply.cpp index fef6f36432..6aec571563 100644 --- a/src/dbus/qdbuspendingreply.cpp +++ b/src/dbus/qdbuspendingreply.cpp @@ -94,7 +94,7 @@ */ /*! - \fn QDBusPendingReply::QDBusPendingReply() + \fn template QDBusPendingReply::QDBusPendingReply() Creates an empty QDBusPendingReply object. Without assigning a QDBusPendingCall object to this reply, QDBusPendingReply cannot do @@ -102,7 +102,7 @@ */ /*! - \fn QDBusPendingReply::QDBusPendingReply(const QDBusPendingReply &other) + \fn template QDBusPendingReply::QDBusPendingReply(const QDBusPendingReply &other) Creates a copy of the \a other QDBusPendingReply object. Just like QDBusPendingCall and QDBusPendingCallWatcher, this QDBusPendingReply @@ -111,7 +111,7 @@ */ /*! - \fn QDBusPendingReply::QDBusPendingReply(const QDBusPendingCall &call) + \fn template QDBusPendingReply::QDBusPendingReply(const QDBusPendingCall &call) Creates a QDBusPendingReply object that will take its contents from the \a call pending asynchronous call. This QDBusPendingReply object @@ -119,7 +119,7 @@ */ /*! - \fn QDBusPendingReply::QDBusPendingReply(const QDBusMessage &message) + \fn template QDBusPendingReply::QDBusPendingReply(const QDBusMessage &message) Creates a QDBusPendingReply object that will take its contents from the message \a message. In this case, this object will be already @@ -129,7 +129,7 @@ */ /*! - \fn QDBusPendingReply &QDBusPendingReply::operator=(const QDBusPendingReply &other) + \fn template QDBusPendingReply &QDBusPendingReply::operator=(const QDBusPendingReply &other) Makes a copy of \a other and drops the reference to the current pending call. If the current reference is to an unfinished pending @@ -139,7 +139,7 @@ */ /*! - \fn QDBusPendingReply &QDBusPendingReply::operator=(const QDBusPendingCall &call) + \fn template QDBusPendingReply &QDBusPendingReply::operator=(const QDBusPendingCall &call) Makes this object take its contents from the \a call pending call and drops the reference to the current pending call. If the @@ -149,7 +149,7 @@ */ /*! - \fn QDBusPendingReply &QDBusPendingReply::operator=(const QDBusMessage &message) + \fn template QDBusPendingReply &QDBusPendingReply::operator=(const QDBusMessage &message) Makes this object take its contents from the \a message message and drops the reference to the current pending call. If the @@ -171,7 +171,7 @@ */ /*! - \fn int QDBusPendingReply::count() const + \fn template int QDBusPendingReply::count() const Return the number of arguments the reply is supposed to have. This number matches the number of non-void template parameters in this @@ -183,7 +183,7 @@ */ /*! - \fn QVariant QDBusPendingReply::argumentAt(int index) const + \fn template QVariant QDBusPendingReply::argumentAt(int index) const Returns the argument at position \a index in the reply's contents. If the reply doesn't have that many elements, this @@ -198,12 +198,7 @@ */ /*! - \typedef QDBusPendingReply::T1 - \internal - */ - -/*! - \fn T1 QDBusPendingReply::value() const + \fn template T1 QDBusPendingReply::value() const Returns the first argument in this reply, cast to type \c T1 (the first template parameter of this class). This is equivalent to @@ -221,7 +216,7 @@ */ /*! - \fn QDBusPendingReply::operator T1() const + \fn template QDBusPendingReply::operator T1() const Returns the first argument in this reply, cast to type \c T1 (the first template parameter of this class). This is equivalent to @@ -239,7 +234,7 @@ */ /*! - \fn void QDBusPendingReply::waitForFinished() + \fn template void QDBusPendingReply::waitForFinished() Suspends the execution of the calling thread until the reply is received and processed. After this function returns, isFinished() diff --git a/src/dbus/qdbuspendingreply.h b/src/dbus/qdbuspendingreply.h index 4d2c3a7c5a..bc5cd92c84 100644 --- a/src/dbus/qdbuspendingreply.h +++ b/src/dbus/qdbuspendingreply.h @@ -108,10 +108,8 @@ namespace QDBusPendingReplyTypes { template <> struct NotVoid { typedef TypeIsVoid Type; }; } // namespace QDBusPendingReplyTypes -#ifndef Q_CLANG_QDOC template -#endif class QDBusPendingReply: #ifdef Q_CLANG_QDOC public QDBusPendingCall @@ -171,7 +169,6 @@ public: QDBusError error() const; QDBusMessage reply() const; - typedef QVariant T1; inline T1 value() const; inline operator T1() const; #else diff --git a/src/dbus/qdbusreply.cpp b/src/dbus/qdbusreply.cpp index ab361f1674..6abfaf174c 100644 --- a/src/dbus/qdbusreply.cpp +++ b/src/dbus/qdbusreply.cpp @@ -81,7 +81,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn template QDBusReply::QDBusReply(const QDBusPendingReply &reply) + \fn template QDBusReply::QDBusReply(const QDBusPendingReply &reply) Constructs a QDBusReply object from the pending reply message, \a reply. */ diff --git a/src/dbus/qdbusreply.h b/src/dbus/qdbusreply.h index 177b6c6e89..869687ac85 100644 --- a/src/dbus/qdbusreply.h +++ b/src/dbus/qdbusreply.h @@ -82,14 +82,10 @@ public: other.waitForFinished(); return *this = other.reply(); } -#if defined(Q_CLANG_QDOC) - inline QDBusReply(const QDBusPendingReply &reply) { } -#else inline QDBusReply(const QDBusPendingReply &reply) { *this = static_cast(reply); } -#endif inline QDBusReply(const QDBusError &dbusError = QDBusError()) : m_error(dbusError), m_data(Type()) diff --git a/src/dbus/qdbusutil.cpp b/src/dbus/qdbusutil.cpp index 28341a71a8..dc94897ac4 100644 --- a/src/dbus/qdbusutil.cpp +++ b/src/dbus/qdbusutil.cpp @@ -331,8 +331,8 @@ namespace QDBusUtil /*! \internal - \fn bool QDBusUtil::isValidPartOfObjectPath(const QStringRef &part) - See QDBusUtil::isValidObjectPath + \fn bool isValidPartOfObjectPath(const QStringRef &part) + See isValidObjectPath */ bool isValidPartOfObjectPath(const QStringRef &part) { @@ -349,13 +349,13 @@ namespace QDBusUtil /*! \internal - \fn bool QDBusUtil::isValidPartOfObjectPath(const QString &part) + \fn bool isValidPartOfObjectPath(const QString &part) \overload */ /*! - \fn bool QDBusUtil::isValidInterfaceName(const QString &ifaceName) + \fn bool isValidInterfaceName(const QString &ifaceName) Returns \c true if this is \a ifaceName is a valid interface name. Valid interface names must: @@ -384,7 +384,7 @@ namespace QDBusUtil } /*! - \fn bool QDBusUtil::isValidUniqueConnectionName(const QStringRef &connName) + \fn bool isValidUniqueConnectionName(const QStringRef &connName) Returns \c true if \a connName is a valid unique connection name. Unique connection names start with a colon (":") and are followed by a list of dot-separated @@ -414,13 +414,13 @@ namespace QDBusUtil } /*! - \fn bool QDBusUtil::isValidUniqueConnectionName(const QString &connName) + \fn bool isValidUniqueConnectionName(const QString &connName) \overload */ /*! - \fn bool QDBusUtil::isValidBusName(const QString &busName) + \fn bool isValidBusName(const QString &busName) Returns \c true if \a busName is a valid bus name. A valid bus name is either a valid unique connection name or follows the rules: @@ -462,7 +462,7 @@ namespace QDBusUtil } /*! - \fn bool QDBusUtil::isValidMemberName(const QStringRef &memberName) + \fn bool isValidMemberName(const QStringRef &memberName) Returns \c true if \a memberName is a valid member name. A valid member name does not exceed 255 characters in length, is not empty, is composed only of ASCII letters, digits and underscores, but does not start with a digit. @@ -482,13 +482,13 @@ namespace QDBusUtil } /*! - \fn bool QDBusUtil::isValidMemberName(const QString &memberName) + \fn bool isValidMemberName(const QString &memberName) \overload */ /*! - \fn bool QDBusUtil::isValidErrorName(const QString &errorName) + \fn bool isValidErrorName(const QString &errorName) Returns \c true if \a errorName is a valid error name. Valid error names are valid interface names and vice-versa, so this function is actually an alias for isValidInterfaceName. */ @@ -498,7 +498,7 @@ namespace QDBusUtil } /*! - \fn bool QDBusUtil::isValidObjectPath(const QString &path) + \fn bool isValidObjectPath(const QString &path) Returns \c true if \a path is valid object path. Valid object paths follow the rules: @@ -529,7 +529,7 @@ namespace QDBusUtil } /*! - \fn bool QDBusUtil::isValidBasicType(int type) + \fn bool isValidBasicType(int type) Returns \c true if \a c is a valid, basic D-Bus type. */ bool isValidBasicType(int c) @@ -538,7 +538,7 @@ namespace QDBusUtil } /*! - \fn bool QDBusUtil::isValidFixedType(int type) + \fn bool isValidFixedType(int type) Returns \c true if \a c is a valid, fixed D-Bus type. */ bool isValidFixedType(int c) @@ -548,7 +548,7 @@ namespace QDBusUtil /*! - \fn bool QDBusUtil::isValidSignature(const QString &signature) + \fn bool isValidSignature(const QString &signature) Returns \c true if \a signature is a valid D-Bus type signature for one or more types. This function returns \c true if it can all of \a signature into valid, individual types and no characters remain in \a signature. @@ -569,7 +569,7 @@ namespace QDBusUtil } /*! - \fn bool QDBusUtil::isValidSingleSignature(const QString &signature) + \fn bool isValidSingleSignature(const QString &signature) Returns \c true if \a signature is a valid D-Bus type signature for exactly one full type. This function tries to convert the type signature into a D-Bus type and, if it succeeds and no characters remain in the signature, it returns \c true. -- cgit v1.2.3 From d761c6278305ef8737daca4bc3e61a119b40e107 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Fri, 6 Apr 2018 01:27:32 +0100 Subject: QDBusServiceWatcher namespace prefix support This allows a user to efficiently watch for services with a common domain prefix. This is exposed in the API via a wildcard character in the service name. For example creating a watcher on "org.mpris*" will match "org.mpris.foo" "org.mpris.bar" and "org.mpris" itself. It will not match org.mprisasdf. Internally the argument match rules have been expanded from a single QStringList to a struct containing args and arg0namespace. This was done so that we can easily use argpath in match rules in the future. Change-Id: I55882ab603cc6ba478e8c0ea9a6800f6e483a50c Reviewed-by: Kai Uwe Broulik Reviewed-by: Thiago Macieira Reviewed-by: David Faure --- src/dbus/qdbusconnection_p.h | 20 ++++++++- src/dbus/qdbusintegrator.cpp | 89 +++++++++++++++++++++++++++++----------- src/dbus/qdbusservicewatcher.cpp | 11 +++++ 3 files changed, 94 insertions(+), 26 deletions(-) (limited to 'src/dbus') diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h index 444d4727fd..84ce21092a 100644 --- a/src/dbus/qdbusconnection_p.h +++ b/src/dbus/qdbusconnection_p.h @@ -121,6 +121,15 @@ public: QSocketNotifier *write; }; + struct ArgMatchRules { + QStringList args; + QString arg0namespace; + bool operator==(const ArgMatchRules &other) const { + return args == other.args && + arg0namespace == other.arg0namespace; + } + }; + struct SignalHook { inline SignalHook() : obj(0), midx(-1) { } @@ -128,7 +137,7 @@ public: QObject* obj; int midx; QVector params; - QStringList argumentMatch; + ArgMatchRules argumentMatch; QByteArray matchRule; }; @@ -207,12 +216,19 @@ public: QDBusMessage sendWithReplyLocal(const QDBusMessage &message); QDBusPendingCallPrivate *sendWithReplyAsync(const QDBusMessage &message, QObject *receiver, const char *returnMethod, const char *errorMethod,int timeout = -1); + bool connectSignal(const QString &service, const QString &path, const QString& interface, const QString &name, const QStringList &argumentMatch, const QString &signature, QObject *receiver, const char *slot); bool disconnectSignal(const QString &service, const QString &path, const QString& interface, const QString &name, const QStringList &argumentMatch, const QString &signature, QObject *receiver, const char *slot); + bool connectSignal(const QString &service, const QString &path, const QString& interface, + const QString &name, const ArgMatchRules &argumentMatch, const QString &signature, + QObject *receiver, const char *slot); + bool disconnectSignal(const QString &service, const QString &path, const QString& interface, + const QString &name, const ArgMatchRules &argumentMatch, const QString &signature, + QObject *receiver, const char *slot); void registerObject(const ObjectTreeNode *node); void unregisterObject(const QString &path, QDBusConnection::UnregisterMode mode); void connectRelay(const QString &service, @@ -332,7 +348,7 @@ public: static bool prepareHook(QDBusConnectionPrivate::SignalHook &hook, QString &key, const QString &service, const QString &path, const QString &interface, const QString &name, - const QStringList &argMatch, + const ArgMatchRules &argMatch, QObject *receiver, const char *signal, int minMIdx, bool buildSignature); static DBusHandlerResult messageFilter(DBusConnection *, DBusMessage *, void *); diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 03de5b0091..cee5c821c8 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -338,7 +338,7 @@ void QDBusConnectionPrivate::_q_newConnection(QDBusConnectionPrivate *newConnect static QByteArray buildMatchRule(const QString &service, const QString &objectPath, const QString &interface, - const QString &member, const QStringList &argMatch, const QString & /*signature*/) + const QString &member, const QDBusConnectionPrivate::ArgMatchRules &argMatch, const QString & /*signature*/) { QString result = QLatin1String("type='signal',"); QString keyValue = QLatin1String("%1='%2',"); @@ -353,11 +353,14 @@ static QByteArray buildMatchRule(const QString &service, result += keyValue.arg(QLatin1String("member"), member); // add the argument string-matching now - if (!argMatch.isEmpty()) { + if (!argMatch.args.isEmpty()) { keyValue = QLatin1String("arg%1='%2',"); - for (int i = 0; i < argMatch.count(); ++i) - if (!argMatch.at(i).isNull()) - result += keyValue.arg(i).arg(argMatch.at(i)); + for (int i = 0; i < argMatch.args.count(); ++i) + if (!argMatch.args.at(i).isNull()) + result += keyValue.arg(i).arg(argMatch.args.at(i)); + } + if (!argMatch.arg0namespace.isEmpty()) { + result += QStringLiteral("arg0namespace='%1',").arg(argMatch.arg0namespace); } result.chop(1); // remove ending comma @@ -456,21 +459,26 @@ static QObject *findChildObject(const QDBusConnectionPrivate::ObjectTreeNode *ro return 0; } -static QStringList matchArgsForService(const QString &service, QDBusServiceWatcher::WatchMode mode) +static QDBusConnectionPrivate::ArgMatchRules matchArgsForService(const QString &service, QDBusServiceWatcher::WatchMode mode) { - QStringList matchArgs; - matchArgs << service; + QDBusConnectionPrivate::ArgMatchRules matchArgs; + if (service.endsWith(QLatin1Char('*'))) { + matchArgs.arg0namespace = service.chopped(1); + matchArgs.args << QString(); + } + else + matchArgs.args << service; switch (mode) { case QDBusServiceWatcher::WatchForOwnerChange: break; case QDBusServiceWatcher::WatchForRegistration: - matchArgs << QString::fromLatin1("", 0); + matchArgs.args << QString::fromLatin1("", 0); break; case QDBusServiceWatcher::WatchForUnregistration: - matchArgs << QString() << QString::fromLatin1("", 0); + matchArgs.args << QString() << QString::fromLatin1("", 0); break; } return matchArgs; @@ -1310,7 +1318,7 @@ int QDBusConnectionPrivate::findSlot(QObject* obj, const QByteArray &normalizedN bool QDBusConnectionPrivate::prepareHook(QDBusConnectionPrivate::SignalHook &hook, QString &key, const QString &service, const QString &path, const QString &interface, const QString &name, - const QStringList &argMatch, + const ArgMatchRules &argMatch, QObject *receiver, const char *signal, int minMIdx, bool buildSignature) { @@ -1620,14 +1628,14 @@ void QDBusConnectionPrivate::handleSignal(const QString &key, const QDBusMessage continue; if (hook.signature.isEmpty() && !hook.signature.isNull() && !msg.signature().isEmpty()) continue; - if (!hook.argumentMatch.isEmpty()) { + if (!hook.argumentMatch.args.isEmpty()) { const QVariantList arguments = msg.arguments(); - if (hook.argumentMatch.size() > arguments.size()) + if (hook.argumentMatch.args.size() > arguments.size()) continue; bool matched = true; - for (int i = 0; i < hook.argumentMatch.size(); ++i) { - const QString ¶m = hook.argumentMatch.at(i); + for (int i = 0; i < hook.argumentMatch.args.size(); ++i) { + const QString ¶m = hook.argumentMatch.args.at(i); if (param.isNull()) continue; // don't try to match against this if (param == arguments.at(i).toString()) @@ -1638,7 +1646,15 @@ void QDBusConnectionPrivate::handleSignal(const QString &key, const QDBusMessage if (!matched) continue; } - + if (!hook.argumentMatch.arg0namespace.isEmpty()) { + const QVariantList arguments = msg.arguments(); + if (arguments.size() < 1) + continue; + const QString param = arguments.at(0).toString(); + if (param != hook.argumentMatch.arg0namespace + && !param.startsWith(hook.argumentMatch.arg0namespace + QLatin1Char('.'))) + continue; + } activateSignal(hook, msg); } } @@ -2180,10 +2196,21 @@ void QDBusConnectionPrivate::sendInternal(QDBusPendingCallPrivate *pcall, void * } } + bool QDBusConnectionPrivate::connectSignal(const QString &service, const QString &path, const QString &interface, const QString &name, const QStringList &argumentMatch, const QString &signature, QObject *receiver, const char *slot) +{ + ArgMatchRules rules; + rules.args = argumentMatch; + return connectSignal(service, path, interface, name, rules, signature, receiver, slot); +} + +bool QDBusConnectionPrivate::connectSignal(const QString &service, + const QString &path, const QString &interface, const QString &name, + const ArgMatchRules &argumentMatch, const QString &signature, + QObject *receiver, const char *slot) { // check the slot QDBusConnectionPrivate::SignalHook hook; @@ -2241,9 +2268,11 @@ bool QDBusConnectionPrivate::addSignalHook(const QString &key, const SignalHook WatchedServicesHash::mapped_type &data = watchedServices[hook.service]; if (++data.refcount == 1) { // we need to watch for this service changing + ArgMatchRules rules; + rules.args << hook.service; q_dbus_bus_add_match(connection, buildMatchRule(QDBusUtil::dbusService(), QString(), QDBusUtil::dbusInterface(), - QDBusUtil::nameOwnerChanged(), QStringList() << hook.service, QString()), + QDBusUtil::nameOwnerChanged(), rules, QString()), NULL); data.owner = getNameOwnerNoCache(hook.service); qDBusDebug() << this << "Watching service" << hook.service << "for owner changes (current owner:" @@ -2255,9 +2284,19 @@ bool QDBusConnectionPrivate::addSignalHook(const QString &key, const SignalHook return true; } +bool QDBusConnectionPrivate::disconnectSignal(const QString &service, + const QString &path, const QString &interface, const QString &name, + const QStringList &argumentMatch, const QString &signature, + QObject *receiver, const char *slot) +{ + ArgMatchRules rules; + rules.args = argumentMatch; + return disconnectSignal(service, path, interface, name, rules, signature, receiver, slot); +} + bool QDBusConnectionPrivate::disconnectSignal(const QString &service, const QString &path, const QString &interface, const QString &name, - const QStringList &argumentMatch, const QString &signature, + const ArgMatchRules &argumentMatch, const QString &signature, QObject *receiver, const char *slot) { // check the slot @@ -2288,7 +2327,7 @@ bool QDBusConnectionPrivate::removeSignalHook(const QString &key, const SignalHo entry.signature == hook.signature && entry.obj == hook.obj && entry.midx == hook.midx && - entry.argumentMatch == hook.argumentMatch) { + entry.argumentMatch.args == hook.argumentMatch.args) { // no need to compare the parameters if it's the same slot removeSignalHookNoLock(it); return true; // it was there @@ -2330,9 +2369,11 @@ QDBusConnectionPrivate::removeSignalHookNoLock(SignalHookHash::Iterator it) if (sit != watchedServices.end()) { if (--sit.value().refcount == 0) { watchedServices.erase(sit); + ArgMatchRules rules; + rules.args << hook.service; q_dbus_bus_remove_match(connection, buildMatchRule(QDBusUtil::dbusService(), QString(), QDBusUtil::dbusInterface(), - QDBusUtil::nameOwnerChanged(), QStringList() << hook.service, QString()), + QDBusUtil::nameOwnerChanged(), rules, QString()), NULL); } } @@ -2393,7 +2434,7 @@ void QDBusConnectionPrivate::connectRelay(const QString &service, QByteArray sig; sig.append(QSIGNAL_CODE + '0'); sig.append(signal.methodSignature()); - if (!prepareHook(hook, key, service, path, interface, QString(), QStringList(), receiver, sig, + if (!prepareHook(hook, key, service, path, interface, QString(), ArgMatchRules(), receiver, sig, QDBusAbstractInterface::staticMetaObject.methodCount(), true)) return; // don't connect @@ -2414,7 +2455,7 @@ void QDBusConnectionPrivate::disconnectRelay(const QString &service, QByteArray sig; sig.append(QSIGNAL_CODE + '0'); sig.append(signal.methodSignature()); - if (!prepareHook(hook, key, service, path, interface, QString(), QStringList(), receiver, sig, + if (!prepareHook(hook, key, service, path, interface, QString(), ArgMatchRules(), receiver, sig, QDBusAbstractInterface::staticMetaObject.methodCount(), true)) return; // don't disconnect @@ -2447,7 +2488,7 @@ bool QDBusConnectionPrivate::shouldWatchService(const QString &service) */ void QDBusConnectionPrivate::watchService(const QString &service, QDBusServiceWatcher::WatchMode mode, QObject *obj, const char *member) { - QStringList matchArgs = matchArgsForService(service, mode); + ArgMatchRules matchArgs = matchArgsForService(service, mode); connectSignal(QDBusUtil::dbusService(), QString(), QDBusUtil::dbusInterface(), QDBusUtil::nameOwnerChanged(), matchArgs, QString(), obj, member); } @@ -2462,7 +2503,7 @@ void QDBusConnectionPrivate::watchService(const QString &service, QDBusServiceWa */ void QDBusConnectionPrivate::unwatchService(const QString &service, QDBusServiceWatcher::WatchMode mode, QObject *obj, const char *member) { - QStringList matchArgs = matchArgsForService(service, mode); + ArgMatchRules matchArgs = matchArgsForService(service, mode); disconnectSignal(QDBusUtil::dbusService(), QString(), QDBusUtil::dbusInterface(), QDBusUtil::nameOwnerChanged(), matchArgs, QString(), obj, member); } diff --git a/src/dbus/qdbusservicewatcher.cpp b/src/dbus/qdbusservicewatcher.cpp index 0c2fb9118f..b0bfe7254d 100644 --- a/src/dbus/qdbusservicewatcher.cpp +++ b/src/dbus/qdbusservicewatcher.cpp @@ -139,6 +139,17 @@ void QDBusServiceWatcherPrivate::removeService(const QString &service) QDBusConnectionInterface::serviceOwnerChanged() signal because it allows one to receive only the signals for which the class is interested in. + Ending a service name with the character '*' will match all service names + within the specified namespace. + + For example "com.example.backend1*" will match + \list + \li com.example.backend1 + \li com.example.backend1.foo + \li com.example.backend1.foo.bar + \endlist + Substrings in the same domain will not be matched, i.e "com.example.backend12". + \sa QDBusConnection */ -- cgit v1.2.3 From 030b17ecc099ab3191b9b7a43a61560cf3d43f29 Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Thu, 22 Nov 2018 11:58:14 +0100 Subject: QDBusConnection: prevent leaking connection/server on destroy Amends fix 68964b1023 Change-Id: I05816f4b4d2128ed0b669e124d9c9eef92122ec0 Reviewed-by: Alex Blasche Reviewed-by: Thiago Macieira --- src/dbus/qdbusintegrator.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/dbus') diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 03de5b0091..dfef25e3a8 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1062,10 +1062,11 @@ QDBusConnectionPrivate::~QDBusConnectionPrivate() "Timer and socket errors will follow and the program will probably crash", qPrintable(name)); + auto lastMode = mode; // reset on connection close closeConnection(); qDeleteAll(cachedMetaObjects); - if (mode == ClientMode || mode == PeerMode) { + if (lastMode == ClientMode || lastMode == PeerMode) { // the bus service object holds a reference back to us; // we need to destroy it before we finish destroying ourselves Q_ASSERT(ref.load() == 0); @@ -1077,7 +1078,7 @@ QDBusConnectionPrivate::~QDBusConnectionPrivate() if (connection) q_dbus_connection_unref(connection); connection = 0; - } else if (mode == ServerMode) { + } else if (lastMode == ServerMode) { if (server) q_dbus_server_unref(server); server = 0; -- cgit v1.2.3 From e2093219665b02e9ac2a416412a371aeb60c7750 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 16 Oct 2018 15:29:58 +0200 Subject: Use Q_DISABLE_COPY_MOVE for private classes Change-Id: I3cfcfba892ff4a0ab4e31f308620b445162bb17b Reviewed-by: Giuseppe D'Angelo --- src/dbus/qdbusargument_p.h | 4 ++-- src/dbus/qdbusconnection_p.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/dbus') diff --git a/src/dbus/qdbusargument_p.h b/src/dbus/qdbusargument_p.h index 559f8b1186..b678b9606f 100644 --- a/src/dbus/qdbusargument_p.h +++ b/src/dbus/qdbusargument_p.h @@ -155,7 +155,7 @@ public: bool skipSignature; private: - Q_DISABLE_COPY(QDBusMarshaller) + Q_DISABLE_COPY_MOVE(QDBusMarshaller) }; class QDBusDemarshaller: public QDBusArgumentPrivate @@ -208,7 +208,7 @@ public: QDBusDemarshaller *parent; private: - Q_DISABLE_COPY(QDBusDemarshaller) + Q_DISABLE_COPY_MOVE(QDBusDemarshaller) QString toStringUnchecked(); QDBusObjectPath toObjectPathUnchecked(); QDBusSignature toSignatureUnchecked(); diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h index 84ce21092a..7769b9ea71 100644 --- a/src/dbus/qdbusconnection_p.h +++ b/src/dbus/qdbusconnection_p.h @@ -94,7 +94,7 @@ class QDBusServer; class QDBusErrorInternal { mutable DBusError error; - Q_DISABLE_COPY(QDBusErrorInternal) + Q_DISABLE_COPY_MOVE(QDBusErrorInternal) public: inline QDBusErrorInternal() { q_dbus_error_init(&error); } inline ~QDBusErrorInternal() { q_dbus_error_free(&error); } -- cgit v1.2.3 From 1c55948ee84f7e8ce4ec6532d7e34f4a1f3c3dea Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 20 Feb 2019 16:01:00 +0100 Subject: DBus: verify up to date with dbus-1.12.12 The attirubtion previously only sayd 1.12, so verified up to date at 1.12.12; and tweaked the header slightly to make it easier to verify (content is now in the same order as in the dbus sources). Updated the list of years in which Red Hat claims copyright on various parts. Fixes: QTBUG-72622 Change-Id: Idcec9edbf42860bca61d838e75889a55eb0859d5 Reviewed-by: Thiago Macieira --- src/dbus/dbus_minimal_p.h | 32 ++++++++++++++++---------------- src/dbus/qt_attribution.json | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) (limited to 'src/dbus') diff --git a/src/dbus/dbus_minimal_p.h b/src/dbus/dbus_minimal_p.h index 869c02b59d..243c8ceaba 100644 --- a/src/dbus/dbus_minimal_p.h +++ b/src/dbus/dbus_minimal_p.h @@ -53,7 +53,7 @@ extern "C" { -// Equivalent to dbus-arch-deps.h +// Equivalent to dbus-arch-deps.h (generated from dbus-arch-deps.h.in) typedef qint64 dbus_int64_t; typedef quint64 dbus_uint64_t; typedef qint32 dbus_int32_t; @@ -78,7 +78,7 @@ struct DBusWatch; // which carry the following copyright: /* * Copyright (C) 2002, 2003 CodeFactory AB - * Copyright (C) 2004, 2005 Red Hat, Inc. + * Copyright (C) 2002, 2003, 2004, 2005 Red Hat, Inc. * * Licensed under the Academic Free License version 2.1 * @@ -103,6 +103,20 @@ typedef dbus_uint32_t dbus_unichar_t; typedef dbus_uint32_t dbus_bool_t; /* dbus-shared.h */ +typedef enum +{ + DBUS_BUS_SESSION, /**< The login session bus */ + DBUS_BUS_SYSTEM, /**< The systemwide bus */ + DBUS_BUS_STARTER /**< The bus that started us, if any */ +} DBusBusType; + +typedef enum +{ + DBUS_HANDLER_RESULT_HANDLED, /**< Message has had its effect - no need to run more handlers. */ + DBUS_HANDLER_RESULT_NOT_YET_HANDLED, /**< Message has not had any effect - see if other handlers want it. */ + DBUS_HANDLER_RESULT_NEED_MEMORY /**< Need more memory in order to return #DBUS_HANDLER_RESULT_HANDLED or #DBUS_HANDLER_RESULT_NOT_YET_HANDLED. Please try again later with more memory. */ +} DBusHandlerResult; + #define DBUS_SERVICE_DBUS "org.freedesktop.DBus" #define DBUS_PATH_DBUS "/org/freedesktop/DBus" #define DBUS_PATH_LOCAL "/org/freedesktop/DBus/Local" @@ -124,20 +138,6 @@ typedef dbus_uint32_t dbus_bool_t; #define DBUS_RELEASE_NAME_REPLY_NON_EXISTENT 2 /**< The given name does not exist on the bus */ #define DBUS_RELEASE_NAME_REPLY_NOT_OWNER 3 /**< Service is not an owner of the given name */ -typedef enum -{ - DBUS_BUS_SESSION, /**< The login session bus */ - DBUS_BUS_SYSTEM, /**< The systemwide bus */ - DBUS_BUS_STARTER /**< The bus that started us, if any */ -} DBusBusType; - -typedef enum -{ - DBUS_HANDLER_RESULT_HANDLED, /**< Message has had its effect - no need to run more handlers. */ - DBUS_HANDLER_RESULT_NOT_YET_HANDLED, /**< Message has not had any effect - see if other handlers want it. */ - DBUS_HANDLER_RESULT_NEED_MEMORY /**< Need more memory in order to return #DBUS_HANDLER_RESULT_HANDLED or #DBUS_HANDLER_RESULT_NOT_YET_HANDLED. Please try again later with more memory. */ -} DBusHandlerResult; - /* dbus-memory.h */ typedef void (* DBusFreeFunction) (void *memory); diff --git a/src/dbus/qt_attribution.json b/src/dbus/qt_attribution.json index 69d946ba5c..33eaee1ed1 100644 --- a/src/dbus/qt_attribution.json +++ b/src/dbus/qt_attribution.json @@ -7,7 +7,7 @@ "Description": "D-Bus is a message bus system, a simple way for applications to talk to one another.", "Homepage": "https://www.freedesktop.org/wiki/Software/dbus/", "Version": "Minimal supported is 1.2, compatible up to ...", - "Version": "1.12", + "Version": "dbus-1.12.12", "LicenseId": "AFL-2.1 OR GPL-2.0-or-later", "License": "Academic Free License v2.1, or GNU General Public License v2.0 or later", "LicenseFile": "LIBDBUS-1-LICENSE.txt", -- cgit v1.2.3 From 241533962c56e79fe6809bfa81e3ffb34850942c Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 22 Feb 2019 15:58:11 +0100 Subject: Add ### Qt6 comment requested in code-review Task-number: QTBUG-73484 Change-Id: I7c1c5faf3d32fa21d8d2277ec434084450290156 Reviewed-by: Thiago Macieira --- src/dbus/qdbusargument.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/dbus') diff --git a/src/dbus/qdbusargument.h b/src/dbus/qdbusargument.h index ac650d5f62..94a89a4e08 100644 --- a/src/dbus/qdbusargument.h +++ b/src/dbus/qdbusargument.h @@ -158,6 +158,7 @@ QT_END_NAMESPACE Q_DECLARE_METATYPE(QDBusArgument) QT_BEGIN_NAMESPACE +// ### Qt6: remove the defaulted T * = nullptr from these two (MSVC6 work-around): template inline T qdbus_cast(const QDBusArgument &arg, T * = nullptr) { T item; -- cgit v1.2.3 From 41e7b71c410b77a81d09d3cc2e169ffd7975b4d2 Mon Sep 17 00:00:00 2001 From: Kevin Funk Date: Tue, 12 Mar 2019 11:46:26 +0100 Subject: More nullptr usage in headers Diff generated by running clang-tidy's modernize-use-nullptr checker on the CMake-based Qt version. Skipping src/3rdparty, examples/, tests/ Change-Id: Ib182074e2e2fd52f63093f73b3e2e4c0cb7af188 Reviewed-by: Friedemann Kleint Reviewed-by: Simon Hausmann --- src/dbus/qdbusargument_p.h | 6 +++--- src/dbus/qdbusconnection_p.h | 10 +++++----- src/dbus/qdbusintegrator_p.h | 6 +++--- src/dbus/qdbuspendingcall_p.h | 2 +- src/dbus/qdbuspendingreply.h | 2 +- src/dbus/qdbusutil_p.h | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src/dbus') diff --git a/src/dbus/qdbusargument_p.h b/src/dbus/qdbusargument_p.h index b678b9606f..3553d3d151 100644 --- a/src/dbus/qdbusargument_p.h +++ b/src/dbus/qdbusargument_p.h @@ -71,7 +71,7 @@ class QDBusArgumentPrivate { public: inline QDBusArgumentPrivate(int flags = 0) - : message(0), ref(1), capabilities(flags) + : message(nullptr), ref(1), capabilities(flags) { } virtual ~QDBusArgumentPrivate(); @@ -104,7 +104,7 @@ public: class QDBusMarshaller: public QDBusArgumentPrivate { public: - QDBusMarshaller(int flags) : QDBusArgumentPrivate(flags), parent(0), ba(0), closeCode(0), ok(true), skipSignature(false) + QDBusMarshaller(int flags) : QDBusArgumentPrivate(flags), parent(nullptr), ba(nullptr), closeCode(0), ok(true), skipSignature(false) { direction = Marshalling; } ~QDBusMarshaller(); @@ -161,7 +161,7 @@ private: class QDBusDemarshaller: public QDBusArgumentPrivate { public: - inline QDBusDemarshaller(int flags) : QDBusArgumentPrivate(flags), parent(0) + inline QDBusDemarshaller(int flags) : QDBusArgumentPrivate(flags), parent(nullptr) { direction = Demarshalling; } ~QDBusDemarshaller(); diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h index 7769b9ea71..da67a6c5d4 100644 --- a/src/dbus/qdbusconnection_p.h +++ b/src/dbus/qdbusconnection_p.h @@ -115,7 +115,7 @@ public: struct Watcher { - Watcher(): watch(0), read(0), write(0) {} + Watcher(): watch(nullptr), read(nullptr), write(nullptr) {} DBusWatch *watch; QSocketNotifier *read; QSocketNotifier *write; @@ -132,7 +132,7 @@ public: struct SignalHook { - inline SignalHook() : obj(0), midx(-1) { } + inline SignalHook() : obj(nullptr), midx(-1) { } QString service, path, signature; QObject* obj; int midx; @@ -150,9 +150,9 @@ public: { typedef QVector DataList; - inline ObjectTreeNode() : obj(0), flags(0) { } + inline ObjectTreeNode() : obj(nullptr), flags(0) { } inline ObjectTreeNode(const QString &n) // intentionally implicit - : name(n), obj(0), flags(0) { } + : name(n), obj(nullptr), flags(0) { } inline bool operator<(const QString &other) const { return name < other; } inline bool operator<(const QStringRef &other) const @@ -194,7 +194,7 @@ public: public: // public methods are entry points from other objects - explicit QDBusConnectionPrivate(QObject *parent = 0); + explicit QDBusConnectionPrivate(QObject *parent = nullptr); ~QDBusConnectionPrivate(); void createBusService(); diff --git a/src/dbus/qdbusintegrator_p.h b/src/dbus/qdbusintegrator_p.h index 3cd029a933..0f7e00fde0 100644 --- a/src/dbus/qdbusintegrator_p.h +++ b/src/dbus/qdbusintegrator_p.h @@ -106,7 +106,7 @@ class QDBusCallDeliveryEvent: public QMetaCallEvent public: QDBusCallDeliveryEvent(const QDBusConnection &c, int id, QObject *sender, const QDBusMessage &msg, const QVector &types, int f = 0) - : QMetaCallEvent(0, id, 0, sender, -1), connection(c), message(msg), metaTypes(types), flags(f) + : QMetaCallEvent(0, id, nullptr, sender, -1), connection(c), message(msg), metaTypes(types), flags(f) { } void placeMetaCall(QObject *object) override @@ -126,8 +126,8 @@ class QDBusActivateObjectEvent: public QMetaCallEvent public: QDBusActivateObjectEvent(const QDBusConnection &c, QObject *sender, const QDBusConnectionPrivate::ObjectTreeNode &n, - int p, const QDBusMessage &m, QSemaphore *s = 0) - : QMetaCallEvent(0, ushort(-1), 0, sender, -1, 0, 0, 0, s), connection(c), node(n), + int p, const QDBusMessage &m, QSemaphore *s = nullptr) + : QMetaCallEvent(0, ushort(-1), nullptr, sender, -1, 0, nullptr, nullptr, s), connection(c), node(n), pathStartPos(p), message(m), handled(false) { } ~QDBusActivateObjectEvent(); diff --git a/src/dbus/qdbuspendingcall_p.h b/src/dbus/qdbuspendingcall_p.h index 10f189ae43..e1f6240f3e 100644 --- a/src/dbus/qdbuspendingcall_p.h +++ b/src/dbus/qdbuspendingcall_p.h @@ -99,7 +99,7 @@ public: // } QDBusPendingCallPrivate(const QDBusMessage &sent, QDBusConnectionPrivate *connection) - : sentMessage(sent), connection(connection), watcherHelper(0), pending(0) + : sentMessage(sent), connection(connection), watcherHelper(nullptr), pending(nullptr) { } ~QDBusPendingCallPrivate(); bool setReplyCallback(QObject *target, const char *member); diff --git a/src/dbus/qdbuspendingreply.h b/src/dbus/qdbuspendingreply.h index bc5cd92c84..1d7e60ad7f 100644 --- a/src/dbus/qdbuspendingreply.h +++ b/src/dbus/qdbuspendingreply.h @@ -156,7 +156,7 @@ public: { Q_STATIC_ASSERT_X(Index >= 0 && Index < Count, "Index out of bounds"); typedef typename Select::Type ResultType; - return qdbus_cast(argumentAt(Index), 0); + return qdbus_cast(argumentAt(Index), nullptr); } #endif diff --git a/src/dbus/qdbusutil_p.h b/src/dbus/qdbusutil_p.h index 2f187687b8..5a4b461194 100644 --- a/src/dbus/qdbusutil_p.h +++ b/src/dbus/qdbusutil_p.h @@ -134,7 +134,7 @@ namespace Q_DBUS_NO_EXPORT QDBusUtil return false; } - inline bool checkMemberName(const QString &name, AllowEmptyFlag empty, QDBusError *error, const char *nameType = 0) + inline bool checkMemberName(const QString &name, AllowEmptyFlag empty, QDBusError *error, const char *nameType = nullptr) { if (!nameType) nameType = "member"; if (name.isEmpty()) { -- cgit v1.2.3 From 999c26dd83ad37fcd7a2b2fc62c0281f38c8e6e0 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 1 Feb 2019 12:49:16 +0100 Subject: Add a QAbstractMetaCallEvent And use it to clean up the reimplementations in Qt DBus. Change-Id: I8e3fe35e8db6405cbcbfb45b42a8f2efecc1cef0 Reviewed-by: Thiago Macieira Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/dbus/qdbusabstractinterface.cpp | 4 ++-- src/dbus/qdbusintegrator_p.h | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) (limited to 'src/dbus') diff --git a/src/dbus/qdbusabstractinterface.cpp b/src/dbus/qdbusabstractinterface.cpp index 148bd54147..d49959d8e2 100644 --- a/src/dbus/qdbusabstractinterface.cpp +++ b/src/dbus/qdbusabstractinterface.cpp @@ -66,11 +66,11 @@ namespace { // of to QDBusAbstractInterface::customEvent. // See solution in Patch Set 1 of this change in the Qt Gerrit servers. // (https://codereview.qt-project.org/#/c/126384/1) -class DisconnectRelayEvent : public QMetaCallEvent +class DisconnectRelayEvent : public QAbstractMetaCallEvent { public: DisconnectRelayEvent(QObject *sender, const QMetaMethod &m) - : QMetaCallEvent(0, 0, nullptr, sender, m.methodIndex()) + : QAbstractMetaCallEvent(sender, m.methodIndex()) {} void placeMetaCall(QObject *object) override diff --git a/src/dbus/qdbusintegrator_p.h b/src/dbus/qdbusintegrator_p.h index 0f7e00fde0..44789b3317 100644 --- a/src/dbus/qdbusintegrator_p.h +++ b/src/dbus/qdbusintegrator_p.h @@ -101,36 +101,37 @@ struct QDBusSlotCache Q_DECLARE_SHARED(QDBusSlotCache::Data) Q_DECLARE_SHARED(QDBusSlotCache) -class QDBusCallDeliveryEvent: public QMetaCallEvent +class QDBusCallDeliveryEvent: public QAbstractMetaCallEvent { public: QDBusCallDeliveryEvent(const QDBusConnection &c, int id, QObject *sender, const QDBusMessage &msg, const QVector &types, int f = 0) - : QMetaCallEvent(0, id, nullptr, sender, -1), connection(c), message(msg), metaTypes(types), flags(f) + : QAbstractMetaCallEvent(sender, -1), connection(c), message(msg), metaTypes(types), id(id), flags(f) { } void placeMetaCall(QObject *object) override { - QDBusConnectionPrivate::d(connection)->deliverCall(object, flags, message, metaTypes, id()); + QDBusConnectionPrivate::d(connection)->deliverCall(object, flags, message, metaTypes, id); } private: QDBusConnection connection; // just for refcounting QDBusMessage message; QVector metaTypes; + int id; int flags; }; -class QDBusActivateObjectEvent: public QMetaCallEvent +class QDBusActivateObjectEvent: public QAbstractMetaCallEvent { public: QDBusActivateObjectEvent(const QDBusConnection &c, QObject *sender, const QDBusConnectionPrivate::ObjectTreeNode &n, int p, const QDBusMessage &m, QSemaphore *s = nullptr) - : QMetaCallEvent(0, ushort(-1), nullptr, sender, -1, 0, nullptr, nullptr, s), connection(c), node(n), + : QAbstractMetaCallEvent(sender, -1, s), connection(c), node(n), pathStartPos(p), message(m), handled(false) { } - ~QDBusActivateObjectEvent(); + ~QDBusActivateObjectEvent() override; void placeMetaCall(QObject *) override; @@ -142,15 +143,15 @@ private: bool handled; }; -class QDBusSpyCallEvent : public QMetaCallEvent +class QDBusSpyCallEvent : public QAbstractMetaCallEvent { public: typedef void (*Hook)(const QDBusMessage&); QDBusSpyCallEvent(QDBusConnectionPrivate *cp, const QDBusConnection &c, const QDBusMessage &msg, const Hook *hooks, int count) - : QMetaCallEvent(0, 0, nullptr, cp, 0), conn(c), msg(msg), hooks(hooks), hookCount(count) + : QAbstractMetaCallEvent(cp, 0), conn(c), msg(msg), hooks(hooks), hookCount(count) {} - ~QDBusSpyCallEvent(); + ~QDBusSpyCallEvent() override; void placeMetaCall(QObject *) override; static inline void invokeSpyHooks(const QDBusMessage &msg, const Hook *hooks, int hookCount); -- cgit v1.2.3 From 8d7c97d428cdf89c3419a4e13b62a9849feefce9 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 4 Apr 2019 16:46:41 +0200 Subject: Remove remaining Q_DECL_NOEXCEPT/Q_DECL_NOTHROW usage Change-Id: I91ac9e714a465cab226b211812aa46e8fe5ff2ab Reviewed-by: Thiago Macieira --- src/dbus/qdbusargument.h | 6 +++--- src/dbus/qdbusconnection.h | 6 +++--- src/dbus/qdbuserror.h | 6 +++--- src/dbus/qdbusextratypes.h | 14 +++++++------- src/dbus/qdbusintegrator_p.h | 4 ++-- src/dbus/qdbusmessage.h | 4 ++-- src/dbus/qdbuspendingcall.h | 4 ++-- src/dbus/qdbusunixfiledescriptor.h | 4 ++-- 8 files changed, 24 insertions(+), 24 deletions(-) (limited to 'src/dbus') diff --git a/src/dbus/qdbusargument.h b/src/dbus/qdbusargument.h index 94a89a4e08..7f4bd269a9 100644 --- a/src/dbus/qdbusargument.h +++ b/src/dbus/qdbusargument.h @@ -77,13 +77,13 @@ public: QDBusArgument(); QDBusArgument(const QDBusArgument &other); #ifdef Q_COMPILER_RVALUE_REFS - QDBusArgument(QDBusArgument &&other) Q_DECL_NOTHROW : d(other.d) { other.d = nullptr; } - QDBusArgument &operator=(QDBusArgument &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QDBusArgument(QDBusArgument &&other) noexcept : d(other.d) { other.d = nullptr; } + QDBusArgument &operator=(QDBusArgument &&other) noexcept { swap(other); return *this; } #endif QDBusArgument &operator=(const QDBusArgument &other); ~QDBusArgument(); - void swap(QDBusArgument &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QDBusArgument &other) noexcept { qSwap(d, other.d); } // used for marshalling (Qt -> D-BUS) QDBusArgument &operator<<(uchar arg); diff --git a/src/dbus/qdbusconnection.h b/src/dbus/qdbusconnection.h index 3711981f78..a880a7a939 100644 --- a/src/dbus/qdbusconnection.h +++ b/src/dbus/qdbusconnection.h @@ -132,13 +132,13 @@ public: explicit QDBusConnection(const QString &name); QDBusConnection(const QDBusConnection &other); #ifdef Q_COMPILER_RVALUE_REFS - QDBusConnection(QDBusConnection &&other) Q_DECL_NOTHROW : d(other.d) { other.d = nullptr; } - QDBusConnection &operator=(QDBusConnection &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QDBusConnection(QDBusConnection &&other) noexcept : d(other.d) { other.d = nullptr; } + QDBusConnection &operator=(QDBusConnection &&other) noexcept { swap(other); return *this; } #endif QDBusConnection &operator=(const QDBusConnection &other); ~QDBusConnection(); - void swap(QDBusConnection &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QDBusConnection &other) noexcept { qSwap(d, other.d); } bool isConnected() const; QString baseService() const; diff --git a/src/dbus/qdbuserror.h b/src/dbus/qdbuserror.h index c264f62b7d..5a68a417c4 100644 --- a/src/dbus/qdbuserror.h +++ b/src/dbus/qdbuserror.h @@ -99,17 +99,17 @@ public: QDBusError(ErrorType error, const QString &message); QDBusError(const QDBusError &other); #ifdef Q_COMPILER_RVALUE_REFS - QDBusError(QDBusError &&other) Q_DECL_NOTHROW + QDBusError(QDBusError &&other) noexcept : code(other.code), msg(std::move(other.msg)), nm(std::move(other.nm)) {} - QDBusError &operator=(QDBusError &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QDBusError &operator=(QDBusError &&other) noexcept { swap(other); return *this; } #endif QDBusError &operator=(const QDBusError &other); #ifndef QT_BOOTSTRAPPED QDBusError &operator=(const QDBusMessage &msg); #endif - void swap(QDBusError &other) Q_DECL_NOTHROW + void swap(QDBusError &other) noexcept { qSwap(code, other.code); qSwap(msg, other.msg); diff --git a/src/dbus/qdbusextratypes.h b/src/dbus/qdbusextratypes.h index 12961e2702..e2430ad6f2 100644 --- a/src/dbus/qdbusextratypes.h +++ b/src/dbus/qdbusextratypes.h @@ -59,7 +59,7 @@ class Q_DBUS_EXPORT QDBusObjectPath { QString m_path; public: - QDBusObjectPath() Q_DECL_NOTHROW : m_path() {} + QDBusObjectPath() noexcept : m_path() {} // compiler-generated copy/move constructor/assignment operators are ok! // compiler-generated destructor is ok! @@ -70,7 +70,7 @@ public: explicit QDBusObjectPath(QString &&p) : m_path(std::move(p)) { doCheck(); } #endif - void swap(QDBusObjectPath &other) Q_DECL_NOTHROW { qSwap(m_path, other.m_path); } + void swap(QDBusObjectPath &other) noexcept { qSwap(m_path, other.m_path); } inline void setPath(const QString &path); @@ -114,7 +114,7 @@ class Q_DBUS_EXPORT QDBusSignature { QString m_signature; public: - QDBusSignature() Q_DECL_NOTHROW : m_signature() {} + QDBusSignature() noexcept : m_signature() {} // compiler-generated copy/move constructor/assignment operators are ok! // compiler-generated destructor is ok! @@ -125,7 +125,7 @@ public: explicit QDBusSignature(QString &&sig) : m_signature(std::move(sig)) { doCheck(); } #endif - void swap(QDBusSignature &other) Q_DECL_NOTHROW { qSwap(m_signature, other.m_signature); } + void swap(QDBusSignature &other) noexcept { qSwap(m_signature, other.m_signature); } inline void setSignature(const QString &signature); @@ -168,16 +168,16 @@ class QDBusVariant { QVariant m_variant; public: - QDBusVariant() Q_DECL_NOTHROW : m_variant() {} + QDBusVariant() noexcept : m_variant() {} // compiler-generated copy/move constructor/assignment operators are ok! // compiler-generated destructor is ok! inline explicit QDBusVariant(const QVariant &variant); #ifdef Q_COMPILER_RVALUE_REFS - explicit QDBusVariant(QVariant &&v) Q_DECL_NOTHROW : m_variant(std::move(v)) {} + explicit QDBusVariant(QVariant &&v) noexcept : m_variant(std::move(v)) {} #endif - void swap(QDBusVariant &other) Q_DECL_NOTHROW { qSwap(m_variant, other.m_variant); } + void swap(QDBusVariant &other) noexcept { qSwap(m_variant, other.m_variant); } inline void setVariant(const QVariant &variant); diff --git a/src/dbus/qdbusintegrator_p.h b/src/dbus/qdbusintegrator_p.h index 0f7e00fde0..a6f7651c73 100644 --- a/src/dbus/qdbusintegrator_p.h +++ b/src/dbus/qdbusintegrator_p.h @@ -86,7 +86,7 @@ struct QDBusSlotCache int slotIdx; QVector metaTypes; - void swap(Data &other) Q_DECL_NOTHROW + void swap(Data &other) noexcept { qSwap(flags, other.flags); qSwap(slotIdx, other.slotIdx); @@ -96,7 +96,7 @@ struct QDBusSlotCache typedef QMultiHash Hash; Hash hash; - void swap(QDBusSlotCache &other) Q_DECL_NOTHROW { qSwap(hash, other.hash); } + void swap(QDBusSlotCache &other) noexcept { qSwap(hash, other.hash); } }; Q_DECLARE_SHARED(QDBusSlotCache::Data) Q_DECLARE_SHARED(QDBusSlotCache) diff --git a/src/dbus/qdbusmessage.h b/src/dbus/qdbusmessage.h index 23e04045d8..3e73db70de 100644 --- a/src/dbus/qdbusmessage.h +++ b/src/dbus/qdbusmessage.h @@ -69,12 +69,12 @@ public: QDBusMessage(); QDBusMessage(const QDBusMessage &other); #ifdef Q_COMPILER_RVALUE_REFS - QDBusMessage &operator=(QDBusMessage &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QDBusMessage &operator=(QDBusMessage &&other) noexcept { swap(other); return *this; } #endif QDBusMessage &operator=(const QDBusMessage &other); ~QDBusMessage(); - void swap(QDBusMessage &other) Q_DECL_NOTHROW { qSwap(d_ptr, other.d_ptr); } + void swap(QDBusMessage &other) noexcept { qSwap(d_ptr, other.d_ptr); } static QDBusMessage createSignal(const QString &path, const QString &interface, const QString &name); diff --git a/src/dbus/qdbuspendingcall.h b/src/dbus/qdbuspendingcall.h index 24b1d6a7ca..c521b7d163 100644 --- a/src/dbus/qdbuspendingcall.h +++ b/src/dbus/qdbuspendingcall.h @@ -61,11 +61,11 @@ public: QDBusPendingCall(const QDBusPendingCall &other); ~QDBusPendingCall(); #ifdef Q_COMPILER_RVALUE_REFS - QDBusPendingCall &operator=(QDBusPendingCall &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QDBusPendingCall &operator=(QDBusPendingCall &&other) noexcept { swap(other); return *this; } #endif QDBusPendingCall &operator=(const QDBusPendingCall &other); - void swap(QDBusPendingCall &other) Q_DECL_NOTHROW { qSwap(d, other.d); } + void swap(QDBusPendingCall &other) noexcept { qSwap(d, other.d); } #ifndef Q_CLANG_QDOC // pretend that they aren't here diff --git a/src/dbus/qdbusunixfiledescriptor.h b/src/dbus/qdbusunixfiledescriptor.h index ed3209ceda..6b264a6b86 100644 --- a/src/dbus/qdbusunixfiledescriptor.h +++ b/src/dbus/qdbusunixfiledescriptor.h @@ -62,12 +62,12 @@ public: explicit QDBusUnixFileDescriptor(int fileDescriptor); QDBusUnixFileDescriptor(const QDBusUnixFileDescriptor &other); #if defined(Q_COMPILER_RVALUE_REFS) - QDBusUnixFileDescriptor &operator=(QDBusUnixFileDescriptor &&other) Q_DECL_NOTHROW { swap(other); return *this; } + QDBusUnixFileDescriptor &operator=(QDBusUnixFileDescriptor &&other) noexcept { swap(other); return *this; } #endif QDBusUnixFileDescriptor &operator=(const QDBusUnixFileDescriptor &other); ~QDBusUnixFileDescriptor(); - void swap(QDBusUnixFileDescriptor &other) Q_DECL_NOTHROW + void swap(QDBusUnixFileDescriptor &other) noexcept { qSwap(d, other.d); } bool isValid() const; -- cgit v1.2.3 From 1ef274fb947f86731d062df2128718cc8a0cf643 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 2 Apr 2019 11:51:14 +0200 Subject: Replace qMove with std::move Change-Id: I67df3ae6b5db0a158f86e75b99f422bd13853bc9 Reviewed-by: Thiago Macieira Reviewed-by: Joerg Bornemann --- src/dbus/qdbusabstractinterface.cpp | 2 +- src/dbus/qdbusintegrator.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/dbus') diff --git a/src/dbus/qdbusabstractinterface.cpp b/src/dbus/qdbusabstractinterface.cpp index d49959d8e2..220223d74d 100644 --- a/src/dbus/qdbusabstractinterface.cpp +++ b/src/dbus/qdbusabstractinterface.cpp @@ -185,7 +185,7 @@ bool QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp, void *retu if (reply.signature() != QLatin1String("v")) { QString errmsg = QLatin1String("Invalid signature `%1' in return from call to " DBUS_INTERFACE_PROPERTIES); - lastError = QDBusError(QDBusError::InvalidSignature, qMove(errmsg).arg(reply.signature())); + lastError = QDBusError(QDBusError::InvalidSignature, std::move(errmsg).arg(reply.signature())); return false; } diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 1125480447..16020aabb1 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1196,7 +1196,7 @@ void QDBusConnectionPrivate::doDispatch() PendingMessageList::Iterator end = pendingMessages.end(); for ( ; it != end; ++it) { qDBusDebug() << this << "dequeueing message" << *it; - handleMessage(qMove(*it)); + handleMessage(std::move(*it)); } pendingMessages.clear(); } -- cgit v1.2.3