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