mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 07:35:48 +08:00
Delay setting the DBusConnection for a DBusObject
Previously, the DBusconnection had to be set at construction time and could not be changed over the DBusObject life time. Now a new connection can be set anytime and as often as required. The shared ownership is now also properly implemented by shared pointers. ref T291
This commit is contained in:
committed by
Klaus Basan
parent
01085f24b3
commit
59da68da5e
@@ -27,7 +27,7 @@ namespace XSwiftBus
|
||||
{
|
||||
|
||||
CPlugin::CPlugin()
|
||||
: m_dbusConnection(std::make_unique<CDBusConnection>()), m_menu(CMenu::mainMenu().subMenu("XSwiftBus"))
|
||||
: m_dbusConnection(std::make_shared<CDBusConnection>()), m_menu(CMenu::mainMenu().subMenu("XSwiftBus"))
|
||||
{
|
||||
m_startServerMenuItem = m_menu.item("Start XSwiftBus", [this]{ startServer(CDBusConnection::SessionBus); });
|
||||
m_toggleMessageWindowMenuItem = m_menu.item("Toggle Message Window", [this] { if(m_service) { m_service->toggleMessageBoxVisibility(); } });
|
||||
@@ -61,6 +61,12 @@ namespace XSwiftBus
|
||||
// for (auto &item : m_startServerMenuItems) { item.setEnabled(false); }
|
||||
m_startServerMenuItem.setEnabled(false);
|
||||
|
||||
m_service = std::make_unique<CService>();
|
||||
m_traffic = std::make_unique<CTraffic>();
|
||||
m_weather = std::make_unique<CWeather>();
|
||||
|
||||
m_traffic->setPlaneViewMenu(m_planeViewSubMenu);
|
||||
|
||||
// Todo: retry if it fails
|
||||
bool success = m_dbusConnection->connect(CDBusConnection::SessionBus, xswiftbusServiceName());
|
||||
|
||||
@@ -70,11 +76,12 @@ namespace XSwiftBus
|
||||
return;
|
||||
}
|
||||
|
||||
m_service = new CService(m_dbusConnection.get());
|
||||
m_traffic = new CTraffic(m_dbusConnection.get());
|
||||
m_weather = new CWeather(m_dbusConnection.get());
|
||||
|
||||
m_traffic->setPlaneViewMenu(m_planeViewSubMenu);
|
||||
m_service->setDBusConnection(m_dbusConnection);
|
||||
m_service->registerDBusObjectPath(m_service->InterfaceName(), m_service->ObjectPath());
|
||||
m_traffic->setDBusConnection(m_dbusConnection);
|
||||
m_traffic->registerDBusObjectPath(m_traffic->InterfaceName(), m_traffic->ObjectPath());
|
||||
m_weather->setDBusConnection(m_dbusConnection);
|
||||
m_weather->registerDBusObjectPath(m_weather->InterfaceName(), m_weather->ObjectPath());
|
||||
|
||||
INFO_LOG("XSwiftBus started.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user