summaryrefslogtreecommitdiffstats
path: root/src/dbus
Commit message (Collapse)AuthorAgeFilesLines
...
* Use a dedicated thread for handling incoming libdbus-1 eventsThiago Macieira2015-09-154-38/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | Each application will have one thread dedicated for this, for all QDBusConnections. I wouldn't mind sharing such a thread with other uses in Qt, provided none of them ever block (the QProcessManager thread comes to mind, but it's going away soon). The cost associated with this change in this commit is so far rather minimal. All incoming D-Bus calls need to be handled after an event is posted anyway, to avoid deadlocking on reentering libdbus-1 functions that acquire locks still held. The cost is the one more thread running and the cost of synchronizing them when an event is posted. The benefits far outweigh that cost: no longer will we have problems of QtDBus failing to run if the main system or session connections are used before QCoreApplication is run. Moreover, events can be received and handled in aux threads even if the main thread is blocked on some operation. Note: this commit may not be testable (tst_qdbusconnection may fail) Task-number: QTBUG-43585 Change-Id: Ic5d393bfd36e48a193fcffff13b737556ccd11a8 Reviewed-by: Albert Astals Cid <aacid@kde.org> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Implement the blocking QtDBus call in terms of the non-blocking oneThiago Macieira2015-09-156-86/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This simplifies the code a little by having a single code path. More importantly, we no longer need to call the evil function dbus_connection_send_with_reply_and_block. That function acquires a lock on the socket transport inside libdbus-1, which means all threads need to wait until the one call gets unblocked before they can continue. To do that, this commit reimplements the QDBus::Block part of QDBusConnectionPrivate::sendWithReply by reusing the existing call to sendWithReplyAsync() and then doing a blocking-wait with QDBusPendingCallPrivate::waitForFinished(). By using (Q)DBusPendingCall and the threaded connection approach (next commit), now we never block on the socket. That also means the code to call dbus_pending_call_block() is no longer necessary and the waitForFinished() function itself can be considerably simplified. As a side-effect of no longer blocking, a number of pre-existing race conditions that used to be hidden showed up. Note: this commit deadlocks without the threading (next commits). Task-number: QTBUG-43585 Change-Id: Ic5d393bfd36e48a193fcffff13b73754954a3f7d Reviewed-by: Albert Astals Cid <aacid@kde.org> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Make QDBusConnectionPrivate::send return boolThiago Macieira2015-09-152-14/+7
| | | | | | | | | It used to return the sent message's serial ID, but we never used that. So simply use boolean instead. Change-Id: Ic5d393bfd36e48a193fcffff13b73753ccf47759 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com> Reviewed-by: Albert Astals Cid <aacid@kde.org>
* Use a signal for updating the dispatch statusThiago Macieira2015-09-152-11/+4
| | | | | | | | | | | | | | The cost of connecting a signal may be a bit high, but it's comparable to looking up the invokable method. However, QMetaMethod::invoke has a higher cost than a signal-slot emission -- though in any case they're both dwarfed by the cost of allocating the QMetaCallEvent and the posting of it. This is much more readable, though. Change-Id: Iccecbecbe6288fb3b6d16578fdff3f203b6db29c Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com> Reviewed-by: Albert Astals Cid <aacid@kde.org>
* Use QDBusConnectionPrivate* when QDBusServer receives a new connectionThiago Macieira2015-09-155-17/+34
| | | | | | | | | This is because the socket activity will move to a different thread; QDBusConnectionPrivate* can be queued, QDBusConnection can't easily. Change-Id: I82722016018b7fcfb246cda6043469fadbfd987d Reviewed-by: Albert Astals Cid <aacid@kde.org> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Use QDBusServiceWatcher in QDBusAbstractInterface to track the ownerThiago Macieira2015-09-152-28/+19
| | | | | | | | | | | Instead of connecting to the "NameOwnerChanged" signal. This has better performance, is simpler to implement and is future-proof: when we switch to kdbus, there won't be a "NameOwnerChanged" signal to connect to. On the drawback side, this will use slightly more memory. Change-Id: I5801b8027949f041309567a493000fe7de9bf227 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com> Reviewed-by: Albert Astals Cid <aacid@kde.org>
* Fix deadlock if the last reference is dropped during deliveryThiago Macieira2015-09-153-18/+3
| | | | | | | | | | | | | | | | We increase the reference count of the connection during delivery of an incoming message, so it's possible that the corresponding deref will drop the last reference to the connection: another thread may have called disconnectFromBus/Peer. However, during destruction we try to drain the incoming socket queue, so we need to acquire the dispatch lock again. The solution is to always use deleteLater(), which means the deleteYourself() function is unnecessary. Change-Id: I27eaacb532114dd188c4ffff13d507039fcf7b6a Reviewed-by: Albert Astals Cid <aacid@kde.org> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Remove Q_DECLARE_TYPEINFO that causes a build errorThiago Macieira2015-08-221-1/+0
| | | | | | | | | | ICC doesn't like it qdbusintrospection_p.h(162): error: explicit specialization of class "QTypeInfo<QDBusIntrospection::Argument>" must precede its first use It's used by the QVector in the same class Change-Id: I7de033f80b0e4431b7f1ffff13f958971617b657 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge "Merge remote-tracking branch 'origin/5.5' into dev" into refs/staging/devTimur Pocheptsov2015-08-091-1/+1
|\
| * Merge remote-tracking branch 'origin/5.5' into devFrederik Gladhorn2015-08-061-1/+1
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: doc/global/qt-cpp-defines.qdocconf src/3rdparty/forkfd/forkfd.c src/corelib/codecs/qtextcodec.cpp src/corelib/kernel/qmetatype.cpp src/corelib/tools/qset.qdoc src/gui/accessible/qaccessible.cpp src/gui/image/qpixmapcache.cpp src/opengl/qgl.cpp src/tools/qdoc/generator.cpp src/widgets/kernel/qwidget.cpp tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp Change-Id: I4fbe1fa756a54c6843aa75f4ef70a1069ba7b085
| | * Doc:added doc to undocumented functionsNico Vertriest2015-07-221-1/+1
| | | | | | | | | | | | | | | | | | Task-number: QTBUG-36985 Change-Id: Ic358682b276d67ef804f727bcf14191718613469 Reviewed-by: Topi Reiniö <topi.reinio@digia.com>
* | | QDBusError: Disable function that isn't used in bootstrapped buildsThiago Macieira2015-08-061-0/+2
|/ / | | | | | | | | Change-Id: Id3d5c7bf4d4c45069621ffff13f7b73144537d81 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | Mark QDBus{ObjectPath,Signature,Variant} shared-come-qt6Marc Mutz2015-07-191-12/+19
| | | | | | | | | | | | | | The compiler-generated move operations are ok. Change-Id: Ida994b52e3ee6ce75afd50133e61488b94464eee Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QDBusVariant: add ctor taking QVariant&&Marc Mutz2015-07-191-0/+3
| | | | | | | | | | Change-Id: Ia25c4bd6294955b0e8ea5ecc0c62719423542e84 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QDBusConnection: declare as shared-come-Qt6Marc Mutz2015-07-191-1/+7
| | | | | | | | | | | | | | Requires adding member-swap and (at least in my copy) move operations. Change-Id: I1b638a81e4a41f467e69e352806524039e7b9f27 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Add missing ↵Marc Mutz2015-07-191-0/+1
| | | | | | | | | | | | | | Q_DECLARE_OPERATORS_FOR_FLAGS(QDBusConnection::ConnectionCapabilities) Change-Id: I659ccc00129d20bbae08b277a291d81c6ede80be Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QDBusMessage: declare as shared-come-Qt6Marc Mutz2015-07-181-0/+6
| | | | | | | | | | | | | | | | | | | | Requires adding member-swap and (at least in my copy) move assignment. Since the type does not contain a d == nullptr state, a move constructor isn't yet possible. Change-Id: Iad6939fa30f214591eab1fdf30a2cf1423ffb32a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QDBusError: declare as shared-come-Qt6Marc Mutz2015-07-181-0/+15
| | | | | | | | | | | | | | Requires adding member-swap and (at least in my copy) move operations. Change-Id: I4284484b1f520eb2d9036b993a5b5b70aaea0af9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QDBusArgument: declare as shared-come-Qt6Marc Mutz2015-07-181-0/+7
| | | | | | | | | | | | | | Requires adding member-swap and (at least in my copy) move operations. Change-Id: I0b32c387809c972203c94677616fe0a52143ec3b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QDBusObjectPath: add ctor taking QString&&Marc Mutz2015-07-181-0/+3
| | | | | | | | | | | | | | | | The new constructor cannot be marked nothrow, because it calls non-nothrow doCheck(); Change-Id: I4e5b33c58125091644573ed84e715c7fa946ae09 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QDBusSignature: add ctor taking QString&&Marc Mutz2015-07-181-0/+3
| | | | | | | | | | | | | | | | The new constructor cannot be marked nothrow, because it calls non-nothrow doCheck(); Change-Id: I732fac7a07d46a3ff3be0e4e56de72dd19090737 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Mark QDBusSlotCache{,::Data} sharedMarc Mutz2015-07-181-0/+11
| | | | | | | | | | | | | | The compiler-generated move operations are ok. Change-Id: Iec0fed49d52ace5ca7dae2c7ee53d717a283f15a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QDBusObjectPath / QDBusSignature: add missing =0 on qHash seed argumentMarc Mutz2015-07-101-2/+2
| | | | | | | | | | Change-Id: I68396e319d9204f7e1e9ef8562ffefa7db565057 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* | QtDBus: replace some inefficient QLists with QVectorMarc Mutz2015-07-102-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | QDBusIntrospection::Argument and the QPair are larger than a void*, so holding them in QLists is needlessly inefficient. Worse, the code could come to depend on the fragile property of (inefficient) QLists that references to elements therein never are invalidated. Fix by marking the types movable, if not already done, and holding them in QVector instead. Change-Id: I1cf88287cc3a1d87e1fcd5061ed8d6d19d2f0722 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QtDBus: mark QDBusAdaptorConnector::AdaptorData as primitiveMarc Mutz2015-07-081-0/+1
| | | | | | | | | | | | | | It is held in QVector. Change-Id: I56e95f9a3a64d3e79914098873a382d233754fa3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QDBusConnection: fix misleading placement of Q_DECLARE_FLAGSMarc Mutz2015-07-081-1/+2
| | | | | | | | | | | | | | | | Was placed under an unrelated enum. Move it to the correct one. Change-Id: I0cf1ffc678c4cffae16660acde95183d5ebcad03 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* | dbus: allow dbus_shutdown() on QT_NO_LIBRARY && QT_LINKED_LIBDBUSUlf Hermann2015-07-061-2/+2
| | | | | | | | | | | | | | | | If you statically link in a dbus library you'll have dbus_shutdown() available. Change-Id: Ieeded63838423a14a5530a4edb0ea46dc9b58d18 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* | QtDBus: mark some types as movable come Qt 6Marc Mutz2015-07-061-0/+9
| | | | | | | | | | | | | | | | Marking them movable now would make QLists of these types BiC. Change-Id: I7ae06aec596b349ee05e48f24a077af743450669 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | QtDBus: Use Q_NULLPTR instead of 0 in all public headersMarc Mutz2015-07-047-10/+10
| | | | | | | | | | | | | | | | | | This is in preparation of adding -Wzero-as-null-pointer-constant (or similar) to the headers check. Task-number: QTBUG-45291 Change-Id: If258b503c5ce335ecc22a5176d3e2b21aa7a278a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.5' into devLiang Qi2015-07-012-1/+2
|\| | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/qglobal.cpp src/corelib/global/qglobal.h src/corelib/global/qsysinfo.h src/corelib/global/qsystemdetection.h src/corelib/kernel/qobjectdefs.h src/plugins/plugins.pro tests/auto/widgets/itemviews/qlistview/qlistview.pro Change-Id: Ib55aa79d707c4c1453fb9d697f6cf92211ed665c
| * Fix warning with MSVC 2013Thiago Macieira2015-06-261-0/+1
| | | | | | | | | | | | | | | | | | | | warning C4100: 'name' : unreferenced formal parameter This is despite the new Q_ASSERT "using" its expression even in release mode. Change-Id: Ieebfc4ab72a6493eaa68ffff13ead0574dd78627 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
| * fix usage of wince scopeOswald Buddenhagen2015-06-051-1/+1
| | | | | | | | | | | | | | Fix style issues along the way. Change-Id: Ic6a6de28e198eb0b14c198b802e78845703909b9 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
* | QtDBus: make all Q_DECLARE_SHARED types nothrow move-assignableMarc Mutz2015-06-302-7/+8
| | | | | | | | | | Change-Id: I5b04fb44b632a0bbb290199fc092b3ffd8289650 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | dbus: Use QList::reserve(), reduces reallocations.Sérgio Martins2015-06-233-2/+10
| | | | | | | | | | | | Change-Id: I5d60220c4d3014067a45a3d3553f0523c9fc7c74 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | qDBusRealAddTimeout(): don't create a QList just to check it's emptyMarc Mutz2015-06-171-1/+1
| | | | | | | | | | | | | | | | | | Instead of QHash::keys(value).isEmpty(), use QHash::key(value, 0) == 0 (0 is used a failure indicator three lines down, so it should not be a key in the hash table). Change-Id: I75cc4f7f7540dc5c51a7b8e3add09a0ec6a75e05 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* | Fix conditions for disabling dbus dynamic symbol lookupUlf Hermann2015-06-162-6/+6
| | | | | | | | | | | | | | | | We cannot do this if no library support is present. Incidentally that's the case when bootstrapping, but you can also set the flag manually. Change-Id: I51e167176d0839af5858122630ef623a1c69a106 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* | Merge remote-tracking branch 'origin/5.5' into devSimon Hausmann2015-06-033-3/+12
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/qnamespace.qdoc src/corelib/io/qwindowspipereader.cpp src/corelib/io/qwindowspipereader_p.h src/corelib/statemachine/qstatemachine.cpp src/corelib/statemachine/qstatemachine_p.h src/plugins/platforms/xcb/qxcbconnection.h tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp tests/auto/tools/qmake/tst_qmake.cpp tests/manual/touch/main.cpp Change-Id: I917d694890e79ee3da7d65134b5b085e23e0dd62
| * Make sure we don't call dbus_connection_can_send_type on too old libdbusThiago Macieira2015-05-261-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This function was introduced alongside the support for Unix file descriptors, so it's a good indicator of whether Unix FDs are supported. Ever since dbus_minimal_p.h, however, DBUS_TYPE_UNIX_FD may be defined even if the system libs don't support it. In order to fix this issue, I had to fix what was apparently a merge conflict resolution mistake and remove the #ifdef around the test. Doing the latter is a good idea due to moc being unable to find <dbus/dbus.h>. This was tested with both linked and dynamically-loaded libdbus-1. Task-number: QTBUG-46199 Change-Id: I66a35ce5f88941f29aa6ffff13dfb4b5438613a3 Reviewed-by: Jani Vähäkangas <jani.vahakangas@theqtcompany.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
| * Doc: added doc for non-documented functionsNico Vertriest2015-05-182-0/+12
| | | | | | | | | | | | | | Task-number: QTBUG-36985 Change-Id: I85f58c2877d83b98bf3427cbb0f567575803524f Reviewed-by: Venugopal Shivashankar <venugopal.shivashankar@digia.com> Reviewed-by: Topi Reiniö <topi.reinio@digia.com>
* | Merge remote-tracking branch 'origin/5.5' into devLiang Qi2015-04-222-1/+11
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/statemachine/qstatemachine.cpp src/corelib/statemachine/qstatemachine_p.h src/gui/painting/qdrawhelper.cpp src/plugins/platforms/xcb/qxcbnativeinterface.cpp src/plugins/platforms/xcb/qxcbwindow.cpp src/plugins/platforms/xcb/qxcbwindow.h src/testlib/qtestblacklist.cpp src/tools/qdoc/node.cpp src/tools/qdoc/node.h tests/auto/gui/painting/qcolor/tst_qcolor.cpp Change-Id: I6c78b7b162001712d5774293f501b06b4ff32684
| * Fix undefined behavior: accessing an object after destructionThiago Macieira2015-04-152-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QDBusConnectionPrivate keeps a pointer to a QDBusConnectionInterface, which in turn holds a reference back to that QDBusConnectionPrivate. During the interface object's destruction, the QDBusAbstractInterface's destructor checks if the interface is still valid. That access is undefined behavior, but has so far been benign in all our uses since the memory had not yet been freed (just destroyed) and the reference count went from 0 to -1. To be on the safe side, we destroy now the QDBusConnectionInterface object while the Private is still valid. It will bring the reference count down from 0 to a negative number, but won't cause any other effects. Change-Id: I9a75ad8521ae4e5cbbe5ffff13d1b80057e13809 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
| * Fix crashes on shutdown when the D-Bus spy list has been destroyedThiago Macieira2015-04-151-1/+1
| | | | | | | | | | | | | | | | | | | | The QDBusConnection spy hook is most often created after the QDBusConnectionManager global, which means it will get destroyed before. That means we'll almost surely going to get a null pointer dereference if we handle the socket close to shutdown. Change-Id: I27eaacb532114dd188c4ffff13d4c9dc865b8c02 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* | Remove <qhash.h> where it's not usedMarc Mutz2015-04-203-2/+2
| | | | | | | | | | | | | | | | To avoid source-incompatibilites, wrap in QT_DEPRECATED_SINCE(5, 5) in public headers. Change-Id: I6117e8a6b11200d2f1a0a94a0e87d5c27538218e Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | Replace <qhash.h> with <qhashfunctions.h> where applicableMarc Mutz2015-04-201-0/+3
| | | | | | | | | | | | | | | | To avoid source-incompatibilites, wrap in QT_DEPRECATED_SINCE(5, 5) in public headers. Change-Id: Ic3398f4f330e15a3b55065858add26b90fd70e6c Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* | Merge remote-tracking branch 'origin/5.5' into devLiang Qi2015-04-0112-66/+79
|\| | | | | | | | | | | | | | | Conflicts: src/testlib/qtestblacklist.cpp src/widgets/accessible/qaccessiblewidgets.cpp Change-Id: If032adb9296428f62384ed835dbf41ee7a0b886c
| * Use QStringLiteral where applicable in QtDBusThiago Macieira2015-03-318-61/+64
| | | | | | | | | | | | | | | | | | Move to qdbusutil_p.h the string constants that are used often and in multiple places; use QStringLiteral in qdbusintegrator.cpp for the strings that are used often. Change-Id: I8e1325b9ba015bda91bf01c42175d8032ea32f62 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
| * Use QDebugStateSaver to restore space setting in stream operators.Friedemann Kleint2015-03-303-4/+8
| | | | | | | | | | | | | | | | Returning dbg.space() breaks formatting on streams that already have nospace() set. Change-Id: I55e38b018679a67eb40be6b4664505483a3a7d8e Reviewed-by: David Faure <david.faure@kdab.com>
| * Skip non-exported slots early when creating a XML interface description.Robert Griebl2015-03-251-1/+6
| | | | | | | | | | | | | | | | This will prevent unnecessary warnings about unknown types for signals or slots that are not even exported to the D-Bus. Change-Id: Iecda5beca5ebe6665a193245fe1c2578156f6abe Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * Export the symbols of libdbus-1 when loading it at runtime.Robert Griebl2015-03-251-0/+1
| | | | | | | | | | | | | | | | | | This allows applications that need additional symbols from the library to easily obtain them without needing to replicate the library open logic from qdbus_symbols.cpp. Change-Id: Ic65ef6684637fbcd1c9f4fe1dc7a57f0624b61a8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.5' into devSimon Hausmann2015-03-161-2/+2
|\| | | | | | | | | | | | | | | Conflicts: src/plugins/platforms/xcb/qxcbnativeinterface.cpp src/plugins/platforms/xcb/qxcbnativeinterface.h Change-Id: I31b38ba439b9341d51a01c0fd54bea33f7410076