1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-09 07:36:48 +02:00

Remove script objects automatically from ScriptAccount when they are deleted

This commit is contained in:
Dominik Schmidt
2015-01-05 04:11:17 +01:00
parent 3c1e1ea35c
commit c840dbbf78
2 changed files with 10 additions and 0 deletions

View File

@@ -92,6 +92,7 @@ ScriptAccount::registerScriptPlugin( const QString& type, const QString& objectI
if( !object ) if( !object )
{ {
object = new ScriptObject( objectId, this ); object = new ScriptObject( objectId, this );
connect( object, SIGNAL( destroyed( QObject* ) ), SLOT( onScriptObjectDeleted( QObject* ) ) );
m_objects.insert( objectId, object ); m_objects.insert( objectId, object );
} }
@@ -99,6 +100,13 @@ ScriptAccount::registerScriptPlugin( const QString& type, const QString& objectI
} }
void
ScriptAccount::onScriptObjectDeleted( QObject* scriptObject )
{
m_objects.remove( m_objects.key( static_cast< ScriptObject* >( scriptObject ) ) );
}
void void
ScriptAccount::scriptPluginFactory( const QString& type, ScriptObject* object ) ScriptAccount::scriptPluginFactory( const QString& type, ScriptObject* object )
{ {

View File

@@ -55,6 +55,8 @@ public:
private slots: private slots:
void onJobDeleted( const QString& jobId ); void onJobDeleted( const QString& jobId );
void onScriptObjectDeleted( QObject* scriptObject );
private: // TODO: pimple, might be renamed before tho private: // TODO: pimple, might be renamed before tho
QString m_name; QString m_name;
QHash< QString, ScriptJob* > m_jobs; QHash< QString, ScriptJob* > m_jobs;