From 9f3f4551511b63a3f230a8d71718d0d5fa352a28 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 8 Jul 2013 18:15:37 -0700 Subject: Fix disconnectFrom{Peer,Bus} when the connection failed If the connection failed, the DBusConnection object is null, but we still add our QDBusConnectionPrivate to the global hash (maybe we shouldn't). Both disconnectFromXXX functions check that they are disconnecting a connection of the right type, but we never initialized the type if the connection failed. So simply make sure we initialize before handling the error state. Task-number: QTBUG-27973 Change-Id: I96f4825ab1b71adf1b72caf4f72db41742b44a55 Reviewed-by: Frederik Gladhorn --- src/dbus/qdbusintegrator.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/dbus/qdbusintegrator.cpp') diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index afb8506b28..d5c359aea1 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1681,13 +1681,13 @@ static dbus_int32_t server_slot = -1; void QDBusConnectionPrivate::setServer(DBusServer *s, const QDBusErrorInternal &error) { + mode = ServerMode; if (!s) { handleError(error); return; } server = s; - mode = ServerMode; dbus_bool_t data_allocated = q_dbus_server_allocate_data_slot(&server_slot); if (data_allocated && server_slot < 0) @@ -1718,13 +1718,13 @@ void QDBusConnectionPrivate::setServer(DBusServer *s, const QDBusErrorInternal & void QDBusConnectionPrivate::setPeer(DBusConnection *c, const QDBusErrorInternal &error) { + mode = PeerMode; if (!c) { handleError(error); return; } connection = c; - mode = PeerMode; q_dbus_connection_set_exit_on_disconnect(connection, false); q_dbus_connection_set_watch_functions(connection, @@ -1771,13 +1771,13 @@ static QDBusConnection::ConnectionCapabilities connectionCapabilies(DBusConnecti void QDBusConnectionPrivate::setConnection(DBusConnection *dbc, const QDBusErrorInternal &error) { + mode = ClientMode; if (!dbc) { handleError(error); return; } connection = dbc; - mode = ClientMode; const char *service = q_dbus_bus_get_unique_name(connection); Q_ASSERT(service); -- cgit v1.2.3