diff options
author | Harald Fernengel <harald.fernengel@nokia.com> | 2013-12-13 10:59:03 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-21 20:06:20 +0100 |
commit | 11096f5d89d3243036d30bb3586f35d6b3f96497 (patch) | |
tree | bf10fdb967eb17a15d5c10cdcbe7b3a333f4b3ff /src/qdbus | |
parent | 4799a620e646a82d3759544a3d54e56d2183c0fc (diff) |
Better error message if dbus libs unavailable
If the D-Bus libraries cannot be loaded, the DBusConnection would
have a null d-pointer, thus have no QDBusError.
Change-Id: Ibeca6eae84c84c886c173817c9c83e76d45346a0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/qdbus')
-rw-r--r-- | src/qdbus/qdbus/qdbus.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/qdbus/qdbus/qdbus.cpp b/src/qdbus/qdbus/qdbus.cpp index 0349c6008..b03c14319 100644 --- a/src/qdbus/qdbus/qdbus.cpp +++ b/src/qdbus/qdbus/qdbus.cpp @@ -479,9 +479,15 @@ int main(int argc, char **argv) connection = QDBusConnection::sessionBus(); if (!connection.isConnected()) { - fprintf(stderr, "Could not connect to D-Bus server: %s: %s\n", - qPrintable(connection.lastError().name()), - qPrintable(connection.lastError().message())); + const QDBusError lastError = connection.lastError(); + if (lastError.isValid()) { + fprintf(stderr, "Could not connect to D-Bus server: %s: %s\n", + qPrintable(lastError.name()), + qPrintable(lastError.message())); + } else { + // an invalid last error means that we were not able to even load the D-Bus library + fprintf(stderr, "Could not connect to D-Bus server: Unable to load dbus libraries\n"); + } return 1; } |