mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 16:44:05 +02:00
Stop JSResolverHelper on destruction and block any calls
This commit is contained in:
@@ -311,6 +311,8 @@ JSResolver::start()
|
||||
Q_D( JSResolver );
|
||||
|
||||
d->stopped = false;
|
||||
d->resolverHelper->start();
|
||||
|
||||
if ( d->ready )
|
||||
Tomahawk::Pipeline::instance()->addResolver( this );
|
||||
else
|
||||
@@ -582,6 +584,7 @@ JSResolver::stop()
|
||||
Q_D( JSResolver );
|
||||
|
||||
d->stopped = true;
|
||||
d->resolverHelper->stop();
|
||||
|
||||
scriptAccount()->stop();
|
||||
|
||||
|
@@ -74,10 +74,25 @@ JSResolverHelper::JSResolverHelper( const QString& scriptPath, JSResolver* paren
|
||||
: QObject( parent )
|
||||
, m_resolver( parent )
|
||||
, m_scriptPath( scriptPath )
|
||||
, m_stopped( false )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
JSResolverHelper::start()
|
||||
{
|
||||
m_stopped = false;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
JSResolverHelper::stop()
|
||||
{
|
||||
m_stopped = true;
|
||||
}
|
||||
|
||||
|
||||
QByteArray
|
||||
JSResolverHelper::readRaw( const QString& fileName )
|
||||
{
|
||||
@@ -434,6 +449,10 @@ JSResolverHelper::currentCountry() const
|
||||
void
|
||||
JSResolverHelper::nativeReportCapabilities( const QVariant& v )
|
||||
{
|
||||
if( m_stopped )
|
||||
return;
|
||||
|
||||
|
||||
bool ok;
|
||||
int intCap = v.toInt( &ok );
|
||||
Tomahawk::ExternalResolver::Capabilities capabilities;
|
||||
@@ -449,6 +468,9 @@ JSResolverHelper::nativeReportCapabilities( const QVariant& v )
|
||||
void
|
||||
JSResolverHelper::reportScriptJobResults( const QVariantMap& result )
|
||||
{
|
||||
if( m_stopped )
|
||||
return;
|
||||
|
||||
m_resolver->d_func()->scriptAccount->reportScriptJobResult( result );
|
||||
}
|
||||
|
||||
@@ -456,6 +478,9 @@ JSResolverHelper::reportScriptJobResults( const QVariantMap& result )
|
||||
void
|
||||
JSResolverHelper::registerScriptPlugin( const QString& type, const QString& objectId )
|
||||
{
|
||||
if( m_stopped )
|
||||
return;
|
||||
|
||||
m_resolver->d_func()->scriptAccount->registerScriptPlugin( type, objectId );
|
||||
}
|
||||
|
||||
@@ -463,6 +488,9 @@ JSResolverHelper::registerScriptPlugin( const QString& type, const QString& obje
|
||||
void
|
||||
JSResolverHelper::unregisterScriptPlugin( const QString& type, const QString& objectId )
|
||||
{
|
||||
if( m_stopped )
|
||||
return;
|
||||
|
||||
m_resolver->d_func()->scriptAccount->unregisterScriptPlugin( type, objectId );
|
||||
}
|
||||
|
||||
|
@@ -54,6 +54,9 @@ public:
|
||||
*/
|
||||
void setResolverConfig( const QVariantMap& config );
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
/**
|
||||
* Get the instance unique account id for this resolver.
|
||||
*
|
||||
@@ -141,6 +144,7 @@ private:
|
||||
QVariantMap m_resolverConfig;
|
||||
JSResolver* m_resolver;
|
||||
QString m_scriptPath;
|
||||
bool m_stopped;
|
||||
};
|
||||
|
||||
} // ns: Tomahawk
|
||||
|
Reference in New Issue
Block a user