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 <frederik.gladhorn@digia.com>
This commit is contained in:
parent
7e7c689c34
commit
9f3f455151
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user