1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-12 09:04:33 +02:00

Stop JSResolverHelper on destruction and block any calls

This commit is contained in:
Dominik Schmidt
2016-01-05 22:30:49 +01:00
parent e4146c98c7
commit 5aa875c40a
3 changed files with 35 additions and 0 deletions

View File

@@ -311,6 +311,8 @@ JSResolver::start()
Q_D( JSResolver ); Q_D( JSResolver );
d->stopped = false; d->stopped = false;
d->resolverHelper->start();
if ( d->ready ) if ( d->ready )
Tomahawk::Pipeline::instance()->addResolver( this ); Tomahawk::Pipeline::instance()->addResolver( this );
else else
@@ -582,6 +584,7 @@ JSResolver::stop()
Q_D( JSResolver ); Q_D( JSResolver );
d->stopped = true; d->stopped = true;
d->resolverHelper->stop();
scriptAccount()->stop(); scriptAccount()->stop();

View File

@@ -74,10 +74,25 @@ JSResolverHelper::JSResolverHelper( const QString& scriptPath, JSResolver* paren
: QObject( parent ) : QObject( parent )
, m_resolver( parent ) , m_resolver( parent )
, m_scriptPath( scriptPath ) , m_scriptPath( scriptPath )
, m_stopped( false )
{ {
} }
void
JSResolverHelper::start()
{
m_stopped = false;
}
void
JSResolverHelper::stop()
{
m_stopped = true;
}
QByteArray QByteArray
JSResolverHelper::readRaw( const QString& fileName ) JSResolverHelper::readRaw( const QString& fileName )
{ {
@@ -434,6 +449,10 @@ JSResolverHelper::currentCountry() const
void void
JSResolverHelper::nativeReportCapabilities( const QVariant& v ) JSResolverHelper::nativeReportCapabilities( const QVariant& v )
{ {
if( m_stopped )
return;
bool ok; bool ok;
int intCap = v.toInt( &ok ); int intCap = v.toInt( &ok );
Tomahawk::ExternalResolver::Capabilities capabilities; Tomahawk::ExternalResolver::Capabilities capabilities;
@@ -449,6 +468,9 @@ JSResolverHelper::nativeReportCapabilities( const QVariant& v )
void void
JSResolverHelper::reportScriptJobResults( const QVariantMap& result ) JSResolverHelper::reportScriptJobResults( const QVariantMap& result )
{ {
if( m_stopped )
return;
m_resolver->d_func()->scriptAccount->reportScriptJobResult( result ); m_resolver->d_func()->scriptAccount->reportScriptJobResult( result );
} }
@@ -456,6 +478,9 @@ JSResolverHelper::reportScriptJobResults( const QVariantMap& result )
void void
JSResolverHelper::registerScriptPlugin( const QString& type, const QString& objectId ) JSResolverHelper::registerScriptPlugin( const QString& type, const QString& objectId )
{ {
if( m_stopped )
return;
m_resolver->d_func()->scriptAccount->registerScriptPlugin( type, objectId ); m_resolver->d_func()->scriptAccount->registerScriptPlugin( type, objectId );
} }
@@ -463,6 +488,9 @@ JSResolverHelper::registerScriptPlugin( const QString& type, const QString& obje
void void
JSResolverHelper::unregisterScriptPlugin( const QString& type, const QString& objectId ) JSResolverHelper::unregisterScriptPlugin( const QString& type, const QString& objectId )
{ {
if( m_stopped )
return;
m_resolver->d_func()->scriptAccount->unregisterScriptPlugin( type, objectId ); m_resolver->d_func()->scriptAccount->unregisterScriptPlugin( type, objectId );
} }

View File

@@ -54,6 +54,9 @@ public:
*/ */
void setResolverConfig( const QVariantMap& config ); void setResolverConfig( const QVariantMap& config );
void start();
void stop();
/** /**
* Get the instance unique account id for this resolver. * Get the instance unique account id for this resolver.
* *
@@ -141,6 +144,7 @@ private:
QVariantMap m_resolverConfig; QVariantMap m_resolverConfig;
JSResolver* m_resolver; JSResolver* m_resolver;
QString m_scriptPath; QString m_scriptPath;
bool m_stopped;
}; };
} // ns: Tomahawk } // ns: Tomahawk