Skip to content

Commit

Permalink
Merge pull request #73 from krf/fix-multithreaded
Browse files Browse the repository at this point in the history
ObjectListModel: Fix assert in objectRemovedMainThread
  • Loading branch information
krf committed Mar 18, 2014
2 parents d92d8f5 + 40003e7 commit bc0aca9
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions core/objectlistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,20 @@ void ObjectListModel::objectRemovedMainThread(QObject *obj, bool fromBackground)
{
Q_ASSERT(thread() == QThread::currentThread());

if (fromBackground) {
{
QMutexLocker lock(&m_mutex);
bool removed = m_invalidatedObjects.remove(obj);
if (!removed) {
Q_ASSERT(!m_objects.contains(obj));
return;
}
} else {

#ifndef NDEBUG
QMutexLocker lock(&m_mutex);
Q_ASSERT(!m_invalidatedObjects.contains(obj));
if (fromBackground) {
if (!removed) {
Q_ASSERT(!m_objects.contains(obj));
return;
}
}
#else
Q_UNUSED(fromBackground);
Q_UNUSED(removed);
#endif
}

Expand Down

0 comments on commit bc0aca9

Please sign in to comment.