summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2013-04-11 00:14:12 -0700
committerPatrick Ohly <patrick.ohly@intel.com>2013-04-22 15:58:32 +0200
commitc7c0152776f2358dd8dc4c6f21c2853d4c14bbe2 (patch)
treeb32276919b5305a88329e4eff2a7631b122d6bc9
parent2894f5c573ed92c6c9d09cccbbe3b01a3d0f52d9 (diff)
KDE: avoid creating a shared session D-Bus connection before creating the app
Qt has never been happy with the old code, reporting: QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave. This error message became visible again after some recent logging changes and broke tests, so better avoid it by testing for D-Bus with a private connection.
-rw-r--r--src/backends/kde/KDEPlatform.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/backends/kde/KDEPlatform.cpp b/src/backends/kde/KDEPlatform.cpp
index 1b98ccdc..c10eb689 100644
--- a/src/backends/kde/KDEPlatform.cpp
+++ b/src/backends/kde/KDEPlatform.cpp
@@ -52,8 +52,14 @@ void KDEInitMainSlot(const char *appname)
{
// Very simple check. API doesn't say whether asking
// for the bus connection will connect immediately.
- QDBusConnection dbus = QDBusConnection::sessionBus();
- HaveDBus = dbus.isConnected();
+ // We use a private connection here instead of the shared
+ // QDBusConnection::sessionBus() because we don't have
+ // a QCoreApplication yet. Otherwise we get a warning:
+ // "QDBusConnection: session D-Bus connection created before QCoreApplication. Application may misbehave."
+ {
+ QDBusConnection dbus = QDBusConnection::connectToBus(QDBusConnection::SessionBus, "org.syncevolution.kde-platform-test-connection");
+ HaveDBus = dbus.isConnected();
+ }
if (!HaveDBus) {
// KApplication has been seen to crash without D-Bus (BMC #25596).