Merge two more QDBusConnectionPrivate members into a union
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>bb10
parent
75f6f1d843
commit
8888eae0d3
|
|
@ -303,8 +303,10 @@ public:
|
|||
// the dispatch lock protects everything related to the DBusConnection or DBusServer
|
||||
// including the timeouts and watches
|
||||
QMutex dispatchLock;
|
||||
DBusConnection *connection;
|
||||
DBusServer *server;
|
||||
union {
|
||||
DBusConnection *connection;
|
||||
DBusServer *server;
|
||||
};
|
||||
WatcherHash watchers;
|
||||
TimeoutHash timeouts;
|
||||
PendingTimeoutList timeoutsPendingAdd;
|
||||
|
|
|
|||
|
|
@ -949,7 +949,7 @@ extern bool qDBusInitThreads();
|
|||
|
||||
QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p)
|
||||
: QObject(p), ref(1), capabilities(0), mode(InvalidMode), busService(0),
|
||||
dispatchLock(QMutex::Recursive), connection(0), server(0),
|
||||
dispatchLock(QMutex::Recursive), connection(0),
|
||||
rootNode(QString(QLatin1Char('/'))),
|
||||
anonymousAuthenticationAllowed(false)
|
||||
{
|
||||
|
|
@ -995,22 +995,23 @@ QDBusConnectionPrivate::~QDBusConnectionPrivate()
|
|||
rootNode.children.clear(); // free resources
|
||||
qDeleteAll(cachedMetaObjects);
|
||||
|
||||
if (mode == ClientMode) {
|
||||
if (mode == ClientMode || mode == PeerMode) {
|
||||
// the bus service object holds a reference back to us;
|
||||
// we need to destroy it before we finish destroying ourselves
|
||||
Q_ASSERT(ref.load() == 0);
|
||||
QObject *obj = (QObject *)busService;
|
||||
disconnect(obj, Q_NULLPTR, this, Q_NULLPTR);
|
||||
delete obj;
|
||||
if (obj) {
|
||||
disconnect(obj, Q_NULLPTR, this, Q_NULLPTR);
|
||||
delete obj;
|
||||
}
|
||||
if (connection)
|
||||
q_dbus_connection_unref(connection);
|
||||
connection = 0;
|
||||
} else if (mode == ServerMode) {
|
||||
if (server)
|
||||
q_dbus_server_unref(server);
|
||||
server = 0;
|
||||
}
|
||||
|
||||
if (server)
|
||||
q_dbus_server_unref(server);
|
||||
if (connection)
|
||||
q_dbus_connection_unref(connection);
|
||||
|
||||
connection = 0;
|
||||
server = 0;
|
||||
}
|
||||
|
||||
void QDBusConnectionPrivate::closeConnection()
|
||||
|
|
@ -1020,7 +1021,7 @@ void QDBusConnectionPrivate::closeConnection()
|
|||
mode = InvalidMode; // prevent reentrancy
|
||||
baseService.clear();
|
||||
|
||||
if (server) {
|
||||
if (oldMode == ServerMode && server) {
|
||||
q_dbus_server_disconnect(server);
|
||||
q_dbus_server_free_data_slot(&server_slot);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue