1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-23 17:29:42 +01:00

Fix crash on exit

This commit is contained in:
Leo Franchi 2012-03-30 13:27:36 -04:00
parent 907dad95e1
commit d623bbefc2
2 changed files with 8 additions and 2 deletions

View File

@ -41,6 +41,7 @@ ScriptResolver::ScriptResolver( const QString& exe )
, m_ready( false )
, m_stopped( true )
, m_configSent( false )
, m_deleting( false )
, m_error( Tomahawk::ExternalResolver::NoError )
{
tLog() << Q_FUNC_INFO << "Created script resolver:" << exe;
@ -61,9 +62,10 @@ ScriptResolver::ScriptResolver( const QString& exe )
ScriptResolver::~ScriptResolver()
{
disconnect( &m_proc, SIGNAL( finished( int, QProcess::ExitStatus ) ), this, SLOT( cmdExited( int, QProcess::ExitStatus ) ) );
m_deleting = true;
m_proc.kill();
m_proc.waitForFinished();
m_proc.waitForFinished(); // might call handleMsg
Tomahawk::Pipeline::instance()->removeResolver( this );
@ -207,6 +209,10 @@ ScriptResolver::handleMsg( const QByteArray& msg )
{
// qDebug() << Q_FUNC_INFO << msg.size() << QString::fromAscii( msg );
// Might be called from waitForFinished() in ~ScriptResolver, no database in that case, abort.
if ( m_deleting )
return;
bool ok;
QVariant v = m_parser.parse( msg, &ok );
if ( !ok || v.type() != QVariant::Map )

View File

@ -85,7 +85,7 @@ private:
quint32 m_msgsize;
QByteArray m_msg;
bool m_ready, m_stopped, m_configSent;
bool m_ready, m_stopped, m_configSent, m_deleting;
ExternalResolver::ErrorState m_error;
QJson::Parser m_parser;