Fix leaks and clean up

wilder-5.14
Kai Uwe Broulik 8 years ago
parent 5cba0ab628
commit 1adfa77c65
  1. 2
      gmenu-dbusmenu-proxy/actions.cpp
  2. 2
      gmenu-dbusmenu-proxy/gmenudbusmenuproxy.desktop
  3. 7
      gmenu-dbusmenu-proxy/menu.cpp
  4. 10
      gmenu-dbusmenu-proxy/window.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();
});
}

@ -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;

Loading…
Cancel
Save