From 96a601d16f400ada5ce5815d566dccba7d7ec5d9 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Mon, 5 Jan 2015 02:42:39 +0100 Subject: [PATCH] Delete ScriptInfoPlugin if underlying ScriptObject dies --- src/libtomahawk/resolvers/ScriptInfoPlugin.cpp | 9 +++++++++ src/libtomahawk/resolvers/ScriptInfoPlugin.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/src/libtomahawk/resolvers/ScriptInfoPlugin.cpp b/src/libtomahawk/resolvers/ScriptInfoPlugin.cpp index 0a6e12b96..2305c0b7e 100644 --- a/src/libtomahawk/resolvers/ScriptInfoPlugin.cpp +++ b/src/libtomahawk/resolvers/ScriptInfoPlugin.cpp @@ -39,6 +39,8 @@ ScriptInfoPlugin::ScriptInfoPlugin( ScriptObject* scriptObject, const QString& n m_supportedPushTypes = parseSupportedTypes( m_scriptObject->syncInvoke( "supportedPushTypes" ) ); setFriendlyName( QString( "ScriptInfoPlugin: %1" ).arg( name ) ); + + connect( scriptObject, SIGNAL( destroyed( QObject* ) ), SLOT( onScriptObjectDeleted() ) ); } @@ -47,6 +49,13 @@ ScriptInfoPlugin::~ScriptInfoPlugin() } +void +ScriptInfoPlugin::onScriptObjectDeleted() +{ + deleteLater(); +} + + void ScriptInfoPlugin::init() { diff --git a/src/libtomahawk/resolvers/ScriptInfoPlugin.h b/src/libtomahawk/resolvers/ScriptInfoPlugin.h index cab46ba96..9365748b8 100644 --- a/src/libtomahawk/resolvers/ScriptInfoPlugin.h +++ b/src/libtomahawk/resolvers/ScriptInfoPlugin.h @@ -54,6 +54,9 @@ protected slots: void onGetInfoRequestDone( const QVariantMap& result ); void onNotInCacheRequestDone( const QVariantMap& result ); + // boilerplate: to be removed with Qt5 (can be put into ScriptPlugin) + void onScriptObjectDeleted(); + private: static QSet< Tomahawk::InfoSystem::InfoType > parseSupportedTypes(const QVariant& variant); static QString serializeQVariantMap(const QVariantMap& map);