From 4240f10260cbffbff52bf2d549100f4690a642b5 Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Wed, 2 Dec 2020 21:09:42 +0100 Subject: Fix callbacks for pluginlist, modlist and download manager. --- src/pluginlistproxy.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'src/pluginlistproxy.cpp') diff --git a/src/pluginlistproxy.cpp b/src/pluginlistproxy.cpp index 1f8dc2b4..b51d108b 100644 --- a/src/pluginlistproxy.cpp +++ b/src/pluginlistproxy.cpp @@ -3,11 +3,24 @@ #include "proxyutils.h" using namespace MOBase; +using namespace MOShared; -PluginListProxy::PluginListProxy(OrganizerProxy* oproxy, IPluginList* pluginlist) : - m_OrganizerProxy(oproxy), m_Proxied(pluginlist) { } +PluginListProxy::PluginListProxy(OrganizerProxy* oproxy, PluginList* pluginlist) : + m_OrganizerProxy(oproxy), m_Proxied(pluginlist) +{ + m_Connections.push_back(m_Proxied->onRefreshed(callSignalIfPluginActive(m_OrganizerProxy, m_Refreshed))); + m_Connections.push_back(m_Proxied->onPluginMoved(callSignalIfPluginActive(m_OrganizerProxy, m_PluginMoved))); + m_Connections.push_back(m_Proxied->onPluginStateChanged(callSignalIfPluginActive(m_OrganizerProxy, m_PluginStateChanged))); +} + +PluginListProxy::~PluginListProxy() +{ + for (auto& conn : m_Connections) { + conn.disconnect(); + } +} -QStringList PluginListProxy::pluginNames() const +QStringList PluginListProxy::pluginNames() const { return m_Proxied->pluginNames(); } @@ -57,17 +70,17 @@ QString PluginListProxy::origin(const QString& name) const return m_Proxied->origin(name); } -bool PluginListProxy::onRefreshed(const std::function& callback) +bool PluginListProxy::onRefreshed(const std::function& func) { - return m_Proxied->onRefreshed(MOShared::callIfPluginActive(m_OrganizerProxy, callback)); + return m_Refreshed.connect(func).connected(); } bool PluginListProxy::onPluginMoved(const std::function& func) { - return m_Proxied->onPluginMoved(MOShared::callIfPluginActive(m_OrganizerProxy, func)); + return m_PluginMoved.connect(func).connected(); } bool PluginListProxy::onPluginStateChanged(const std::function&)> &func) { - return m_Proxied->onPluginStateChanged(MOShared::callIfPluginActive(m_OrganizerProxy, func)); + return m_PluginStateChanged.connect(func).connected(); } -- cgit v1.3.1