diff --git a/gmenu-dbusmenu-proxy/actions.cpp b/gmenu-dbusmenu-proxy/actions.cpp index db584e1db..9709595a0 100644 --- a/gmenu-dbusmenu-proxy/actions.cpp +++ b/gmenu-dbusmenu-proxy/actions.cpp @@ -69,6 +69,7 @@ void Actions::load() m_actions = reply.value(); emit loaded(); } + watcher->deleteLater(); }); } @@ -122,6 +123,7 @@ void Actions::trigger(const QString &name, uint timestamp) if (reply.isError()) { qCWarning(DBUSMENUPROXY) << "Failed to invoke action" << name << "on" << m_serviceName << "at" << m_objectPath << reply.error(); } + watcher->deleteLater(); }); } diff --git a/gmenu-dbusmenu-proxy/gmenudbusmenuproxy.desktop b/gmenu-dbusmenu-proxy/gmenudbusmenuproxy.desktop index 4bd5dc4ef..7a7404b9a 100644 --- a/gmenu-dbusmenu-proxy/gmenudbusmenuproxy.desktop +++ b/gmenu-dbusmenu-proxy/gmenudbusmenuproxy.desktop @@ -4,4 +4,4 @@ Name=GMenuDBusMenuProxy Type=Application X-KDE-StartupNotify=false OnlyShowIn=KDE; -X-KDE-autostart-phase=0 +X-KDE-autostart-phase=1 diff --git a/gmenu-dbusmenu-proxy/menu.cpp b/gmenu-dbusmenu-proxy/menu.cpp index 793f2c228..4e5ba6d90 100644 --- a/gmenu-dbusmenu-proxy/menu.cpp +++ b/gmenu-dbusmenu-proxy/menu.cpp @@ -80,7 +80,9 @@ void Menu::start(uint id) QDBusPendingReply reply = QDBusConnection::sessionBus().asyncCall(msg); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); connect(watcher, &QDBusPendingCallWatcher::finished, this, [this, id](QDBusPendingCallWatcher *watcher) { - QDBusPendingReply reply = *watcher; + QScopedPointer watcherPtr(watcher); + + QDBusPendingReply reply = *watcherPtr; if (reply.isError()) { qCWarning(DBUSMENUPROXY) << "Failed to start subscription to" << id << "on" << m_serviceName << "at" << m_objectPath << reply.error(); emit failedToSubscribe(id); @@ -108,8 +110,6 @@ void Menu::start(uint id) emit subscribed(id); } - - watcher->deleteLater(); }); } @@ -141,6 +141,7 @@ void Menu::stop(const QList &ids) emit menuDisappeared(); } } + watcher->deleteLater(); }); } diff --git a/gmenu-dbusmenu-proxy/window.cpp b/gmenu-dbusmenu-proxy/window.cpp index b24d7633f..b050216b1 100644 --- a/gmenu-dbusmenu-proxy/window.cpp +++ b/gmenu-dbusmenu-proxy/window.cpp @@ -89,7 +89,7 @@ void Window::init() } if (!m_applicationObjectPath.isEmpty()) { - m_applicationActions = new Actions(m_serviceName, m_applicationObjectPath); + m_applicationActions = new Actions(m_serviceName, m_applicationObjectPath, this); connect(m_applicationActions, &Actions::actionsChanged, this, [this](const QStringList &dirtyActions) { onActionsChanged(dirtyActions, s_applicationActionsPrefix); }); @@ -104,7 +104,7 @@ void Window::init() } if (!m_unityObjectPath.isEmpty()) { - m_unityActions = new Actions(m_serviceName, m_unityObjectPath); + m_unityActions = new Actions(m_serviceName, m_unityObjectPath, this); connect(m_unityActions, &Actions::actionsChanged, this, [this](const QStringList &dirtyActions) { onActionsChanged(dirtyActions, s_unityActionsPrefix); }); @@ -119,7 +119,7 @@ void Window::init() } if (!m_windowObjectPath.isEmpty()) { - m_windowActions = new Actions(m_serviceName, m_windowObjectPath); + m_windowActions = new Actions(m_serviceName, m_windowObjectPath, this); connect(m_windowActions, &Actions::actionsChanged, this, [this](const QStringList &dirtyActions) { onActionsChanged(dirtyActions, s_windowActionsPrefix); }); @@ -346,6 +346,8 @@ bool Window::registerDBusObject() static int menus = 0; ++menus; + new DbusmenuAdaptor(this); + const QString objectPath = QStringLiteral("/MenuBar/%1").arg(QString::number(menus)); qCDebug(DBUSMENUPROXY) << "Registering DBus object path" << objectPath; @@ -354,8 +356,6 @@ bool Window::registerDBusObject() return false; } - new DbusmenuAdaptor(this); // do this before registering the object? - m_proxyObjectPath = objectPath; return true;