From 48df87e07f575dae566f4ab2af3dce1131c9d5b8 Mon Sep 17 00:00:00 2001 From: APTX Date: Sat, 15 Mar 2014 14:22:48 +0100 Subject: [PATCH] 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. --- localmylist/mylist.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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; } -- 2.52.0