mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
Make sure we eliminate all references to finished ScriptCommands.
This commit is contained in:
@@ -18,8 +18,6 @@
|
|||||||
|
|
||||||
#include "ScriptCommandQueue.h"
|
#include "ScriptCommandQueue.h"
|
||||||
|
|
||||||
#include "utils/Closure.h"
|
|
||||||
|
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
|
|
||||||
ScriptCommandQueue::ScriptCommandQueue( QObject* parent )
|
ScriptCommandQueue::ScriptCommandQueue( QObject* parent )
|
||||||
@@ -47,11 +45,11 @@ ScriptCommandQueue::nextCommand()
|
|||||||
|
|
||||||
QSharedPointer< ScriptCommand > req = m_queue.first();
|
QSharedPointer< ScriptCommand > req = m_queue.first();
|
||||||
|
|
||||||
NewClosure( req.data(), SIGNAL( done() ),
|
connect( req.data(), SIGNAL( done() ),
|
||||||
this, SLOT( onCommandDone( QSharedPointer< ScriptCommand > ) ), req );
|
this, SLOT( onCommandDone() ) );
|
||||||
|
|
||||||
NewClosure( m_timer, SIGNAL( timeout() ),
|
connect( m_timer, SIGNAL( timeout() ),
|
||||||
this, SLOT( onTimeout( QSharedPointer< ScriptCommand > ) ), req );
|
this, SLOT( onTimeout() ) );
|
||||||
|
|
||||||
m_timer->start( 5000 );
|
m_timer->start( 5000 );
|
||||||
|
|
||||||
@@ -60,28 +58,39 @@ ScriptCommandQueue::nextCommand()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ScriptCommandQueue::onCommandDone( const QSharedPointer< ScriptCommand >& req )
|
ScriptCommandQueue::onCommandDone()
|
||||||
{
|
{
|
||||||
disconnect( this, SLOT( onTimeout( QSharedPointer< ScriptCommand > ) ) );
|
|
||||||
m_timer->stop();
|
m_timer->stop();
|
||||||
|
|
||||||
|
const QSharedPointer< ScriptCommand > req = m_queue.first();
|
||||||
|
|
||||||
m_queue.removeAll( req );
|
m_queue.removeAll( req );
|
||||||
|
|
||||||
|
disconnect( req.data(), SIGNAL( done() ),
|
||||||
|
this, SLOT( onCommandDone() ) );
|
||||||
|
disconnect( m_timer, SIGNAL( timeout() ),
|
||||||
|
this, SLOT( onTimeout() ) );
|
||||||
|
|
||||||
if ( m_queue.count() > 0 )
|
if ( m_queue.count() > 0 )
|
||||||
nextCommand();
|
nextCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ScriptCommandQueue::onTimeout( const QSharedPointer< ScriptCommand >& req )
|
ScriptCommandQueue::onTimeout()
|
||||||
{
|
{
|
||||||
disconnect( this, SLOT( onCommandDone( QSharedPointer< ScriptCommand > ) ) );
|
|
||||||
|
|
||||||
m_timer->stop();
|
m_timer->stop();
|
||||||
|
|
||||||
|
const QSharedPointer< ScriptCommand > req = m_queue.first();
|
||||||
|
|
||||||
req->reportFailure();
|
req->reportFailure();
|
||||||
m_queue.removeAll( req );
|
m_queue.removeAll( req );
|
||||||
|
|
||||||
|
disconnect( req.data(), SIGNAL( done() ),
|
||||||
|
this, SLOT( onCommandDone() ) );
|
||||||
|
disconnect( m_timer, SIGNAL( timeout() ),
|
||||||
|
this, SLOT( onTimeout() ) );
|
||||||
|
|
||||||
if ( m_queue.count() > 0 )
|
if ( m_queue.count() > 0 )
|
||||||
nextCommand();
|
nextCommand();
|
||||||
}
|
}
|
||||||
|
@@ -37,8 +37,8 @@ public:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void nextCommand();
|
void nextCommand();
|
||||||
void onCommandDone( const QSharedPointer< ScriptCommand >& req );
|
void onCommandDone();
|
||||||
void onTimeout( const QSharedPointer< ScriptCommand >& req );
|
void onTimeout();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QQueue< QSharedPointer< ScriptCommand > > m_queue;
|
QQueue< QSharedPointer< ScriptCommand > > m_queue;
|
||||||
|
@@ -73,8 +73,6 @@ ScriptCommand_AllTracks::reportFailure()
|
|||||||
{
|
{
|
||||||
emit tracks( QList< Tomahawk::query_ptr >() );
|
emit tracks( QList< Tomahawk::query_ptr >() );
|
||||||
emit done();
|
emit done();
|
||||||
disconnect();
|
|
||||||
sender()->disconnect( this );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -83,7 +81,5 @@ ScriptCommand_AllTracks::onResolverDone( const QList< Tomahawk::query_ptr >& q )
|
|||||||
{
|
{
|
||||||
emit tracks( q );
|
emit tracks( q );
|
||||||
emit done();
|
emit done();
|
||||||
disconnect();
|
|
||||||
sender()->disconnect( this );
|
|
||||||
//FIXME: find a way to delete this object when its job is done
|
//FIXME: find a way to delete this object when its job is done
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user