mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 02:35:38 +08:00
Unregister DBusObject callback when the object is destroyed
Without that cleanup, DBusConnection might try to call a dangling std::function in case the DBusObject was removed before. That is for example happening during shutdown.
This commit is contained in:
committed by
Klaus Basan
parent
dfd33e40c1
commit
f8cc92341a
@@ -19,7 +19,6 @@
|
||||
#include <dbus/dbus.h>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
namespace XSwiftBus
|
||||
@@ -64,7 +63,10 @@ namespace XSwiftBus
|
||||
bool isConnected() const;
|
||||
|
||||
//! Register a disconnected callback
|
||||
void registerDisconnectedCallback(DisconnectedCallback func);
|
||||
void registerDisconnectedCallback(CDBusObject *obj, DisconnectedCallback func);
|
||||
|
||||
//! Register a disconnected callback
|
||||
void unregisterDisconnectedCallback(CDBusObject *obj);
|
||||
|
||||
//! Register DBus object with interfaceName and objectPath.
|
||||
//! \param object
|
||||
@@ -98,7 +100,7 @@ namespace XSwiftBus
|
||||
CDBusDispatcher *m_dispatcher = nullptr;
|
||||
std::unique_ptr<DBusConnection, DBusConnectionDeleter> m_connection;
|
||||
CDBusError m_lastError;
|
||||
std::vector<DisconnectedCallback> m_disconnectedCallbacks;
|
||||
std::unordered_map<CDBusObject *, DisconnectedCallback> m_disconnectedCallbacks;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user