From: APTX Date: Sat, 15 Mar 2014 13:22:48 +0000 (+0100) Subject: Check if workThread exists before trying to access it. X-Git-Url: https://gitweb.aptx.org/?a=commitdiff_plain;h=48df87e07f575dae566f4ab2af3dce1131c9d5b8;p=localmylist.git Check if workThread exists before trying to access it. This can only happen if workThread wasn't created and you're trying to get a Database from a wrong thread. --- diff --git a/localmylist/mylist.cpp b/localmylist/mylist.cpp index 39cfc70..a1f616d 100644 --- a/localmylist/mylist.cpp +++ b/localmylist/mylist.cpp @@ -88,8 +88,14 @@ Database *MyList::database() const if (QThread::currentThread() == thread()) return db; // QThread is in the thread that created it. - if (QThread::currentThread() == workThread->database()->thread()) + if (workThread && QThread::currentThread() == workThread->database()->thread()) return workThread->database(); + + qWarning("Tried to get a database from a different thread. Qt database " + "plugins are not thread-safe. This extends to the LML Database. " + "You can only use a Database from the thread in which MyList was " + "created."); + return 0; }