Commit 1adfa77c authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

Fix leaks and clean up

parent 5cba0ab6
......@@ -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();
});
}
......
......@@ -4,4 +4,4 @@ Name=GMenuDBusMenuProxy
Type=Application
X-KDE-StartupNotify=false
OnlyShowIn=KDE;
X-KDE-autostart-phase=0
X-KDE-autostart-phase=1
......@@ -80,7 +80,9 @@ void Menu::start(uint id)
QDBusPendingReply<GMenuItemList> reply = QDBusConnection::sessionBus().asyncCall(msg);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this, id](QDBusPendingCallWatcher *watcher) {
QDBusPendingReply<GMenuItemList> reply = *watcher;
QScopedPointer<QDBusPendingCallWatcher, QScopedPointerDeleteLater> watcherPtr(watcher);
QDBusPendingReply<GMenuItemList> 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<uint> &ids)
emit menuDisappeared();
}
}
watcher->deleteLater();
});
}
......
......@@ -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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment