From ef41c80eb1c15f88fa797c7ce2e60954f6035702 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Fri, 13 Jan 2012 08:52:30 -0500 Subject: [PATCH] Move the mutex locker in the query's destructor to try to ensure that no part of the destructor can be happening while access happens some other way. Also actually lock the mutex in refreshResults() and check for validity of the object. --- src/libtomahawk/query.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libtomahawk/query.cpp b/src/libtomahawk/query.cpp index 11391d8b1..ed3852eca 100644 --- a/src/libtomahawk/query.cpp +++ b/src/libtomahawk/query.cpp @@ -102,9 +102,9 @@ Query::Query( const QString& query, const QID& qid ) Query::~Query() { + QMutexLocker lock( &s_mutex ); if ( !id().isEmpty() ) { - QMutexLocker lock( &s_mutex ); if ( s_queries.contains( id() ) ) { s_queries.remove( id() ); @@ -206,7 +206,9 @@ Query::refreshResults() if ( m_resolveFinished ) { m_resolveFinished = false; - Pipeline::instance()->resolve( s_queries.value( id() ) ); + QMutexLocker lock( &s_mutex ); + if ( s_queries.contains( id() ) && !s_queries[ id() ].isNull() ) + Pipeline::instance()->resolve( s_queries.value( id() ) ); } }