diff --git a/src/libtomahawk/resolvers/JSResolver.cpp b/src/libtomahawk/resolvers/JSResolver.cpp index bb0507918..9e3ceb0e1 100644 --- a/src/libtomahawk/resolvers/JSResolver.cpp +++ b/src/libtomahawk/resolvers/JSResolver.cpp @@ -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(); diff --git a/src/libtomahawk/resolvers/JSResolverHelper.cpp b/src/libtomahawk/resolvers/JSResolverHelper.cpp index 6ae6a639c..62a9eff5e 100644 --- a/src/libtomahawk/resolvers/JSResolverHelper.cpp +++ b/src/libtomahawk/resolvers/JSResolverHelper.cpp @@ -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 ); } diff --git a/src/libtomahawk/resolvers/JSResolverHelper.h b/src/libtomahawk/resolvers/JSResolverHelper.h index 8790cb49b..3187332f1 100644 --- a/src/libtomahawk/resolvers/JSResolverHelper.h +++ b/src/libtomahawk/resolvers/JSResolverHelper.h @@ -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