summaryrefslogtreecommitdiffstats
path: root/src/dbus
Commit message (Collapse)AuthorAgeFilesLines
* Make QDBusConnectionPrivate::relaySignal be called in the right threadThiago Macieira2016-09-161-4/+2
| | | | | | | | | | | | | | | | | | | | | | | This function sends D-Bus messages directly (in huntAndEmit), so it should only be called from the QDBusConnectionManager thread. Somehow, I missed this in the Qt 5.6 refactoring of QtDBus. Being called in the wrong thread means that there's a visible behavior change compared to Qt 5.5: if the user code sent a method call or method return/error and then emitted a signal, we'd have two threads racing to send the D-Bus messages. This was observed in Telepathy-Qt code: certain signals arrived before a method return, even though they were clearly emitted by a queued QMetaObject::invokeMethod. In addition to that, we have has an internal problem (though not observed): the libdbus-1 timer and socket callbacks would be called in the wrong thread and we no longer have protection against that. Unit testing not possible since this is a race condition. Change-Id: I9e96ecd4f6aa4ff0ae08fffd1471d002142613d6 Reviewed-by: Gustavo Pichorim Boiko <gustavo.boiko@canonical.com> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
* QDBusError: don't bother dealing with unusable 'unused' fieldMarc Mutz2016-09-151-3/+4
| | | | | | | | | | | | | | | | | The move constructor as well as member-swap were dealing with the 'unused' field as if it would be usable. But as the comment in the default ctor suggests, the field can never be used in Qt 5, due to the inline dtor. So, don't bother with the field. Doing so only triggers checkers such as Coverity. Also mark the field for removal in Qt 6. Coverity-Id: 154503 Coverity-Id: 154510 Change-Id: If42c5ed66d1133e651de7477f3313b3989b64bc9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDBusServer: delay processing of D-Bus messagesAlberto Mardegan2016-09-064-20/+33
| | | | | | | | | | We must ensure that QDBusServer's newConnection() signal has been processed by the application, before starting processing messages on it. Task-number: QTBUG-55087 Change-Id: I595329b2f98788dbf9f40558b8c230c0c0817ef8 Reviewed-by: Timo Jyrinki <timo.jyrinki@iki.fi> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Remove repository name from examplesinstallpathTopi Reinio2016-05-121-1/+1
| | | | | | | | Examples in binary packages now directly match the install path. Change-Id: Ic1487bc766cfd3b0a0a340cc4ae4ba49d953eaa6 Task-number: QTBUG-52953 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* Disconnect signals from each QObject only once in QDBusConnectionPrivateThiago Macieira2016-05-092-12/+21
| | | | | | | | | | | | Because the moment we disconnect from the object's destroyed() signal, it may get destroyed in another thread. If the same object appears more than once in the object tree or in the signal hook table, we could be accessing a dangling pointer. Task-number: QTBUG-52988 Change-Id: Ifea6e497f11a461db432ffff14496f0f83889104 Reviewed-by: Weng Xuetian <wengxt@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Workaround Windows DLL unload issue with threads runningThiago Macieira2016-05-021-0/+35
| | | | | | | | | | | | We don't know why it happens, so let's apply a workaround. See the comment for more details. Task-number: QTBUG-53031 Change-Id: Ifea6e497f11a461db432ffff144972e892fbbda5 Reviewed-by: Roland Winklmeier <Roland.M.Winklmeier@gmail.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove the use of QMutexPool from QtDBus loading of libdbus-1Thiago Macieira2016-04-301-2/+3
| | | | | | Change-Id: Ifea6e497f11a461db432ffff1449b013c2302d38 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* QtDBus: finish all pending call with error if disconnectedWeng Xuetian2016-04-284-6/+42
| | | | | | | | | libdbus will send a local signal if connection gets disconnected. When this happens, end all pending calls with QDBusError::Disconnected. Task-number: QTBUG-51649 Change-Id: I5c7d2a468bb5da746d0c0e53e458c1e376f186a9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* dbus: make QDBusArgumentPrivate destructor virtualPeter Wu2016-04-221-1/+1
| | | | | | | | | | | | | Make the destructor of QDBusArgumentPrivate virtual as it may store other types (QDBusDemarshaller). Suggested by Thiago. Fixes a "new-delete-type-mismatch" error reported by AddressSanitizer. Task-number: QTBUG-52176 Change-Id: I9ac19050840530ca9cae893b10093185d31e0448 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: David Faure <david.faure@kdab.com>
* QtDBus: clean up signal hooks and object tree in closeConnectionWeng Xuetian2016-04-082-1/+26
| | | | | | | | | | | | | If a QObject is added or passed as receiver to QDBusConnection::connect() and it is managed by Q_GLOBAL_STATIC or similar mechanism, it is possible that when that its destructor is called after the dbus daemon thread ends. In that case, QObject::destroyed connected via Qt::BlockingQueuedConnection to QDBusConnectionPrivate will cause dead lock since the thread is no longer processing events. Task-number: QTBUG-51648 Change-Id: I1a1810a6d6d0234af0269d5f3fc1f54101bf1547 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix QtDBus deadlock inside kded/kiodThiago Macieira2016-03-192-10/+33
| | | | | | | | | | | | | | | | | | | Whenever a message spy was installed, we failed to actually process looped-back messages by queueing them for processing by the spy. That had as a consequence that the caller got an error reply. Worse, since the message had been queued, QtDBus would attempt to deliver it later. Since that message had isLocal==true, bad things happened inside the manager thread. The correct solution is not to queue the message for the filter. If the message is local, then simply deliver directly, as we're still in the user's thread. This used to be the behavior in Qt 5.5. Task-number: QTBUG-51676 Change-Id: I1dc112894cde7121e8ce302ae51b438ade1ff612 Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Dmitry Shachnev <mitya57@gmail.com> Reviewed-by: Jan Kundrát <jkt@kde.org>
* Merge remote-tracking branch 'origin/5.6.0' into 5.6Frederik Gladhorn2016-03-171-2/+2
|\ | | | | | | Change-Id: Iac8ff05cd76cbacf859138a73e8e2ed0a979c75a
| * Fix crash when a standard bus isn't availableThiago Macieira2016-02-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Commit 1f6fa1f37a14742ddf53c753ce52d9dc048cd1dc added a way of suspending delivery of messages to standard buses when they connect and resuming delivery when the main loop starts. As a side-effect, we caused an attempt to do dispatching even after the connection failed. The D-Bus library doesn't like that. Task-number: QTBUG-51299 Change-Id: I0c94a5c2846b48c8aea7ffff143564f7fcede890 Reviewed-by: David Faure <david.faure@kdab.com>
* | consistently put {qt,qml}_{module,plugin} at the end of project filesOswald Buddenhagen2016-03-071-2/+2
|/ | | | | | | | this fixes static builds by ensuring that all dependencies are exported. Task-number: QTBUG-51071 Change-Id: Icbce502dcbcb4d4b4d922c42679f44e2cc930bf3 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
* Fix dbus wince buildAndreas Holzammer2016-02-053-0/+11
| | | | | | | | | | | interface is a define under wince. This define is included even with standard header includes already. It needs to be undefined for using it. Task-number: QTBUG-50853 Change-Id: Ie44681f03709848e9747a8aec11835c8d62aa409 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix QT_DEPRECATED_SINCE usageJędrzej Nowacki2016-02-021-1/+1
| | | | | | | | The deprecation was introduced in 5.6 Change-Id: Ief6b749b40ec75c3c9f904caed8447bfb5ef5439 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* QtDBus: Remove unnecessary #ifndef for QT_NO_PROPERTIESThiago Macieira2016-01-301-2/+0
| | | | | | | | qfeatures.txt says that it depends on PROPERTIES, so this condition will never happen. Change-Id: I42e7ef1a481840699a8dffff1409e2e63c6857fa Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Call out to QtDBus message spies in the main threadThiago Macieira2016-01-253-13/+57
| | | | | | | | | | | | | | | | | | | | | Whenever there are spies installed, we call out to the main thread to call to the kded/kiod message spies. This allows the spy code to do just about anything, where previously it was restricted in what it could do to avoid deadlocking or triggering assertions if it recursed back into QDBusConnection code in the manager thread. After the spies are done, the message is re-inserted into the QDBusConnection processing pipeline. This commit moves the spy handling to after the check for disabled dispatching, as doing otherwise would mean the message could get postponed again for no good reason. It's also possible that the main thread isn't done installing the hooks, so waiting until the dispatching is enabled is a good idea. For simplicity, this commit also restricts spying to method calls only. Signals are no longer spyable. Change-Id: I3d11545be52c43119f0fffff142b0e9d447415c2 Reviewed-by: David Faure <david.faure@kdab.com>
* Revert "dbus: Print out 'serial' and 'serial reply to' with DBusMessage ↵Thiago Macieira2016-01-112-10/+4
| | | | | | | | | | operator<<." This reverts commit d3fe4f066f70bc8e4aef06b963444ecdbc3dd00f. Required to revert the parent commit. Change-Id: I1039e2ee65c0cd2c3209ea18bd3bd2d84a8daef3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Revert "dbus: Add method serial() and replySerial() to class DBusMessage."Thiago Macieira2016-01-114-47/+0
| | | | | | | | | This reverts commit 618e2cc081e09d9222418bd933876224675a7530. The original commit has a section of code that I failed to review properly and is of questionable functionality. Change-Id: I61c53d7b8b2aa7c3312292b017a18aba7da11bc5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Work around GCC 6 warning about offset outside bounds of stringThiago Macieira2016-01-081-2/+2
| | | | | | | | | | | | | | This is a false positive because the only offset that can be outside the bounds was the last one (-1), which could not be reached in this line because of the qBound on the line before limiting the maximum value. The -1 wasn't generated by the Perl script embedded in the file anyway. qdbuserror.cpp:142:64: error: offset outside bounds of constant string [-Werror] Change-Id: I24a735698d3c4a719fc9ffff1425f8aad5e5978e Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com>
* dbus: Print out 'serial' and 'serial reply to' with DBusMessage operator<<.Ralf Habacker2016-01-072-4/+10
| | | | | | | | | | | | The reply serial is displayed for method call returns and errors, while the serial is displayed for all message types. To see a message serial it is required to dump messages after sending, not before. Task-number: QTBUG-44490 Change-Id: I859f50d739ed059d5b2dfe1a2efdf04b906891a7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* dbus: Add method serial() and replySerial() to class DBusMessage.Ralf Habacker2016-01-074-0/+47
| | | | | | | | | | | | | This patch includes setup of class member 'msg' in QDBusMessagePrivate::toDBusMessage() to be able to get the serial after message sending. Testcases for comparing the 'reply serial to' with the 'serial' are included. Task-number: QTBUG-44490 Change-Id: Iae7c48f5b0c70a6c5ae500904072b38b46dfd876 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Suspend processing of some messages in the default busses by defaultThiago Macieira2016-01-025-7/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To retain a bit compatibility with applications developed in the last 9 years that expect that QDBusConnections won't process their events until the event loop runs, we now suspend the handling of incoming messages in the two default buses (and only in them) and resume when the event loop starts. This is required because the new threaded QtDBus would otherwise process incoming messages that the application didn't expect it to. For example, if the application first acquires names on the bus and only after that registers objects with QtDBus, there's a small window in which the name is acquired and visible to other applications, but no objects are registered yet. Calls to those objects may be received, would then be processed in the QDBusConnectionManager thread and fail. The work around is to disable the actual handling of method calls and signals in QDBusConnectionPrivate::handleMessage. Instead, those messages are queued until later. Due to the way that libdbus-1 works, outgoing method calls that are waiting for replies are not affected, since their processing does not happen in handleMessage(). [ChangeLog][Important Behavior Changes] QtDBus now uses threads to implement processing of incoming and outgoing messages. This solves a number of thread safety issues and fixes an architectural problem that would cause all processing to stop if a particular thread (usually the main thread) were blocked in any operation. On the flip side, application developers need to know that modifications to a QDBusConnection may be visible immediately on the connection, so they should be done in an order that won't allow for incomplete states to be observed (for example, first register all objects, then acquire service names). Change-Id: I39cc61d0d59846ab8c23ffff1423c6d555f6ee0a Reviewed-by: David Faure <david.faure@kdab.com>
* Add a default argument to QDBusPendingCallWatcher::finished signalThiago Macieira2016-01-021-1/+1
| | | | | | | | So we can do connect(&watcher, SIGNAL(finished()), receiver, SLOT(foo())); Change-Id: I39cc61d0d59846ab8c23ffff14241d33fecf2d53 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Remove unused member variable QDBusConnectionPrivate::timeoutsPendingAddThiago Macieira2016-01-021-2/+0
| | | | | | | | They're never pending, since we add them immediately since commit 186d8814407ccb3e221537d9797172c37127bc51. Change-Id: I39cc61d0d59846ab8c23ffff14241be6785ad5a0 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Change a QList of pointers to QVectorThiago Macieira2015-12-291-1/+1
| | | | | | | | | | | QList of pointers is optimum, but QVector should provide the same performance (we aren't using the beginning-of-list feature that QList has and QVector doesn't). But since we're using QVector elsewhere, this should be better. Change-Id: I39cc61d0d59846ab8c23ffff14241c6715e2eb00 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Doc: Update examplesinstallpath to include the repository nameTopi Reinio2015-10-211-1/+1
| | | | | | | | | | | | The examplesinstallpath variable in .qdocconf files defines the path under QT_INSTALL_EXAMPLES where examples are found. To match the way examples are packaged in Qt 5.6, prefix each install path with the repository name. Task-number: QTBUG-48736 Change-Id: I6a35c94fdacaad21cd044411aba02027b9019300 Reviewed-by: Venugopal Shivashankar <venugopal.shivashankar@digia.com>
* QDBusServer: Fix uninitialized memberThiago Macieira2015-10-151-4/+2
| | | | | | | | | | If you used the QString constructor overload and passed an empty address, the d pointer would remain uninitialized. Found by Coverity, CID 11724. Change-Id: I42e7ef1a481840699a8dffff1407ead3ee703d6e Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* QDBusConnection: Remove unused membersThiago Macieira2015-10-151-3/+0
| | | | | | | I can't find any use, ever, of them. Change-Id: I42e7ef1a481840699a8dffff1407eb1a93b128a8 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* QDBusPendingCall: Remove unused memberThiago Macieira2015-10-152-2/+0
| | | | | | | | We set it to the number of types that the call expects to receive, but we never used it anywhere else. Change-Id: I42e7ef1a481840699a8dffff1407eb520b5844d8 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Fix crash in QMetaProperty::write for custom types and conversionOlivier Goffart2015-10-091-0/+3
| | | | | | | | | | | | | | | | if t >= QMetaType::User, we would not return false nor call convert. We would then pass a pointer to whatever is in the QVariant to the qt_metacall that is expecting a pointer to an object of a different type. Since we have custom converters, we can call QVarent::convert even for custom types anyway. [ChangeLog][QtCore] Fixed crash when setting a QVariant of a different type to a property of a custom type. Attempt to do a conversion instead. Task-number: QTBUG-40644 Change-Id: Ib6fbd7e7ddcf25c5ee247ea04177e079f6d7de35 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
* Fix documentation of new methodLars Knoll2015-10-081-2/+2
| | | | | Change-Id: I7accaac765f5514b67279b640de7f98c8042c35a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: replace \target with \keyword if at start of pageNico Vertriest2015-10-021-1/+1
| | | | | | | | | | | | | A \target whose purpose is to link to the top of a page (and not to a section within a page) works better as a \keyword, because \target generates a new html anchor which, in this case, is not tied to any title element on the page. A \keyword links to the page itself, as expected. Task-number: QTBUG-48482 Change-Id: I957551edd0eb7e665358d04b37dab41e2686b851 Reviewed-by: Topi Reiniö <topi.reinio@digia.com>
* Fix missing "We mean it" in qtbase private headersThiago Macieira2015-10-011-0/+11
| | | | | Change-Id: I42e7ef1a481840699a8dffff1408dfd4fd9c8e32 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Fix deadlock on disconnectNotify() called from ~QObjectThiago Macieira2015-09-253-13/+55
| | | | | | | | | | | | | | | | | | | | | | | | | Normally, disconnectNotify() is called at the end of QObject::disconnect and all the locks have been dropped. That is not the case for the QObject destructor, so we need to deal with the fact that it there may be some locks held. I didn't catch this issue during testing because it depends on the pointer addresses of the object being destroyed and that of the QDBusAbstractInterface sender object, as we use one global, non- recursive mutex pool. For the same reason, this patch is not testable. The fix is simple: we don't need to remove the relay rules immediately. It's ok for them to happen later, since the worst case scenario is that we'll receive a few more signals than we have objects to deliver them to. If that happens, we'll do a little more work than we have to. But in the normal case, the amount of work is the same and we get the benefit of returning more quickly from the destructor. What's more, if the QDBusAbstractInterface object also gets destroyed, the events are deleted and QDBusConnectionPrivate will clean everything up. Task-number: QTBUG-48410 Change-Id: I42e7ef1a481840699a8dffff1406b789ba5217b3 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* QtDBus: update debugging info (QDBUS_DEBUG=1)Thiago Macieira2015-09-241-10/+4
| | | | | Change-Id: I9a75ad8521ae4e5cbbe5ffff13d1a740643ec22e Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Merge two more QDBusConnectionPrivate members into a unionThiago Macieira2015-09-152-15/+18
| | | | | | | | | | | QDBusConnectionPrivate can only be a client or a server, not both, so the DBusServer and DBusConnection pointers can be shared, like the QDBusConnectionInterface and QDBusServer pointers in the other anonymous union. Change-Id: I9a75ad8521ae4e5cbbe5ffff13d1baa8ab83c42f Reviewed-by: Albert Astals Cid <aacid@kde.org> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Make sure we don't deadlock when connecting signalsThiago Macieira2015-09-153-51/+40
| | | | | | | | | | | | This commit moves the code that finishes the signal-slot connection into the QtDBus auxiliary thread. That is necessary because we're holding the lock for writing while making blocking calls. The auxiliary thread might be waiting for us to release that lock while processing some previous message. Change-Id: Iee8cbc07c4434ce9b560ffff13d0521b94a51833 Reviewed-by: Albert Astals Cid <aacid@kde.org> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Bypass connectSignal() for receiving the NameOwnerChanged signalThiago Macieira2015-09-151-6/+17
| | | | | | | | | | | | | | | | | This is an optimization but is required. Instead of going through the entire (dis)connectSignal() stack to add/remove matching rules for the NameOwnerChanged bus signal and call into our serviceOwnerChangedNoLock slot, create a static hook that will match the signal and simply add/ remove the rules as needed. The required part is that this avoids a recursion into connectSignal(). The next commit will move this code to the QtDBus manager thread and we won't be able to call connectSignal() from there (it would create a deadlock). Change-Id: Iee8cbc07c4434ce9b560ffff13d074ce90ad02d4 Reviewed-by: Albert Astals Cid <aacid@kde.org> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Make QDBusConnectionPrivate::getNameOwnerNoCache work in our threadThiago Macieira2015-09-151-3/+15
| | | | | | | | | | | | | | | In two commits, we will attempt to call this function from the manager thread, so we need to be sure this function works from there. Right now, it would deadlock in QDBusPendingCallPrivate::waitForFinished(), inside QDBusConnectionPrivate::sendWithReply(). The solution is simple: expand sendWithReply to the sendWithReplyAsync function it calls anyway, but tell the internal DBusPendingCall to finish before we call waitForFinished(). Change-Id: Iee8cbc07c4434ce9b560ffff13d0749013d771ab Reviewed-by: Albert Astals Cid <aacid@kde.org> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Use the new QDBusConnectionPrivate::shouldWatchService functionThiago Macieira2015-09-151-3/+1
| | | | | | | | | That function was added in the previous commit, so deduplicate the code from QDBusAbstractInterfacePrivate::initOwnerTracking(). Change-Id: Iee8cbc07c4434ce9b560ffff13d06f1d9fb0cde5 Reviewed-by: Albert Astals Cid <aacid@kde.org> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* QDBusServiceWatcher: Move the logic to QDBusConnectionPrivateThiago Macieira2015-09-154-37/+80
| | | | | | | | | | | With kdbus, we won't have a regular signal, but instead a special message. So keep the logic of what to do in QDBusConnectionPrivate. The #ifdef is to make sure the bootstrapped qdbuscpp2xml continues to build in cross-compilation environments. Change-Id: Iee8cbc07c4434ce9b560ffff13d06f0d9904cb6d Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Remove the event callbacks in QDBusConnectionPrivateThiago Macieira2015-09-153-149/+19
| | | | | | | | | | | | | | | | | | | | | They were used when we called the libdbus-1 message-sending functions from any thread, which meant that the callbacks could be triggered on any thread. Since we moved the message-sending to one thread only (the manager's thread), there's no need for the event fallback anymore. Since they're also always[*] running on an aux thread, there's no point in checking for the presence of a QCoreApplication instance anymore. I don't think there has been a need for this for many years, as the event dispatcher has been decoupled from QCoreApplication for a long time. [*] exception: the callbacks are first called in the thread that invoked QDBusConnection::connectTo{Bus,Peer}, before we've done the moveToThread. Task-number: QTBUG-43585 Change-Id: Ic5d393bfd36e48a193fcffff13b73758c798d6b0 Reviewed-by: Albert Astals Cid <aacid@kde.org> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Merge two Q_GLOBAL_STATICS into another and solve memory leakThiago Macieira2015-09-153-26/+30
| | | | | | | | | | | | | | | | | | | | | | | The two global statics for the session and system buses aren't necessary if they can't outlive the global static for QDBusConnectionManager anyway. So merge them there. The extra mutex is necessary because the QDBusConnection::connectToBus function will lock the regular mutex. This solves a potential memory leak at exit as a side-effect. Before this change, the session and system QDBusConnection object got destroyed in the main thread during global destruction, so it had to post an event to the QDBusConnectionManager thread to finish the destruction of the private. However, QCoreApplication is already gone by this point, so the QEvent::DeferredDelete event never got delivered. After this commit, there's no global static to destroy the QDBusConnection (there is no QDBusConnection holding a reference), so the object gets destroyed in QDBusConnectionManager::run()'s cleanup code. Change-Id: I9a75ad8521ae4e5cbbe5ffff13d1b967ee1a7a7e Reviewed-by: Albert Astals Cid <aacid@kde.org> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* And move the creation of connections to the threadThiago Macieira2015-09-156-95/+142
| | | | | | | | | | Now we know that all timers and socket notifiers get created only in the QDBusConnectionManager thread. Incidentally, this reduced code duplication. Change-Id: I27eaacb532114dd188c4ffff13d5075a8d2efb0b Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* And move the sending of other types of D-Bus messages to the threadThiago Macieira2015-09-153-12/+15
| | | | | | | | | | With this, we now know that all messages sent are sent from the same thread. This simplifies greatly the handling of the socket. Task-number: QTBUG-43585 Change-Id: Ic5d393bfd36e48a193fcffff13b73758087344ed Reviewed-by: Albert Astals Cid <aacid@kde.org> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Move the sending of the D-Bus messages with reply to the threadThiago Macieira2015-09-153-8/+18
| | | | | | | | | | | This is intended to simply the handling of the socket in the future. Now, we know that all calls to send_with_reply are placed only from the manager's thread. Task-number: QTBUG-43585 Change-Id: Ic5d393bfd36e48a193fcffff13b737575c231927 Reviewed-by: Albert Astals Cid <aacid@kde.org> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Remove superfluous code in QDBusConnectionPrivate::sendWithReplyThiago Macieira2015-09-151-6/+0
| | | | | | | | | | | | No need to check for the local loop if that's the first thing QDBusConnectionPrivate::sendWithReplyAsync will do. The side effect is that this now allocates memory for the QDBusPendingCallPrivate object, but loopback messages aren't that common to be worth the special casing. Task-number: QTBUG-43585 Change-Id: Ic5d393bfd36e48a193fcffff13b73756ab802ba2 Reviewed-by: Albert Astals Cid <aacid@kde.org> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
* Simplify some code in QDBusConnectionPrivate::sendWithReplyAsyncThiago Macieira2015-09-151-24/+11
| | | | | | | | | | | They're pretty much the same, clearly a copy & paste. Instead, merge the two codepaths so that we don't run the risk of applying a change in one part and forgetting the other. Task-number: QTBUG-43585 Change-Id: Ic5d393bfd36e48a193fcffff13b737560f6753be Reviewed-by: Albert Astals Cid <aacid@kde.org> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>