From 3c1e1ea35c2892980e09da87a42fc8e1cf4d1c3e Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Mon, 5 Jan 2015 04:09:55 +0100 Subject: [PATCH] Remove info plugins automatically from InfoSystemWorker when they are deleted --- .../infosystem/InfoSystemWorker.cpp | 23 +++++++++++++++++++ src/libtomahawk/infosystem/InfoSystemWorker.h | 1 + 2 files changed, 24 insertions(+) diff --git a/src/libtomahawk/infosystem/InfoSystemWorker.cpp b/src/libtomahawk/infosystem/InfoSystemWorker.cpp index 592b09d82..184abf1d4 100644 --- a/src/libtomahawk/infosystem/InfoSystemWorker.cpp +++ b/src/libtomahawk/infosystem/InfoSystemWorker.cpp @@ -136,6 +136,29 @@ InfoSystemWorker::addInfoPlugin( Tomahawk::InfoSystem::InfoPluginPtr plugin ) emit updatedSupportedGetTypes( QSet< InfoType >::fromList( m_infoGetMap.keys() ) ); emit updatedSupportedPushTypes( QSet< InfoType >::fromList( m_infoPushMap.keys() ) ); + + connect( plugin.data(), SIGNAL( destroyed( QObject* ) ), SLOT( onInfoPluginDeleted() ) ); +} + + +void +InfoSystemWorker::onInfoPluginDeleted() +{ + foreach( const InfoPluginPtr& plugin, m_plugins ) + { + if ( plugin.isNull() ) + { + m_plugins.removeOne( plugin ); + foreach( InfoType type, m_infoGetMap.keys() ) + { + m_infoGetMap[type].removeOne( plugin ); + } + foreach( InfoType type, m_infoPushMap.keys() ) + { + m_infoPushMap[type].removeOne( plugin ); + } + } + } } diff --git a/src/libtomahawk/infosystem/InfoSystemWorker.h b/src/libtomahawk/infosystem/InfoSystemWorker.h index 0e3851f02..15f43c0ba 100644 --- a/src/libtomahawk/infosystem/InfoSystemWorker.h +++ b/src/libtomahawk/infosystem/InfoSystemWorker.h @@ -72,6 +72,7 @@ public slots: private slots: void checkTimeoutsTimerFired(); + void onInfoPluginDeleted(); private: void registerInfoTypes( const InfoPluginPtr &plugin, const QSet< InfoType > &getTypes, const QSet< InfoType > &pushTypes );