From 57336afea191f0aa3318ee4d13365b5b0d3f9c51 Mon Sep 17 00:00:00 2001 From: APTX Date: Thu, 18 Apr 2013 03:24:51 +0200 Subject: [PATCH] Return the right database for the current thread. --- localmylist/mylist.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/localmylist/mylist.cpp b/localmylist/mylist.cpp index b4636bf..f794c3d 100644 --- a/localmylist/mylist.cpp +++ b/localmylist/mylist.cpp @@ -78,7 +78,10 @@ void MyList::setHostName(QString name) Database *MyList::database() const { - return db; + if (QThread::currentThread() == thread()) + return db; + // FIXME figure work thread case + return workThread->database(); } Settings *MyList::settings() const @@ -102,7 +105,7 @@ void MyList::markWatched(int fid, QDateTime when) request.fid = fid; request.setMyWatched = true; request.myWatched = when; - db->addPendingMyListUpdate(request); + database()->addPendingMyListUpdate(request); } @@ -289,7 +292,7 @@ QString MyList::mapPathFromSource(const QString &path, int sourceHost) if (sourceHost == hostId()) return path; - QList mappings = db->getMappingsToHost(hostId()); + QList mappings = database()->getMappingsToHost(hostId()); foreach(const PathMapping &pm, mappings) { @@ -316,7 +319,7 @@ QString MyList::mapPathFromSource(const QString &path, int sourceHost) QString MyList::mapPathToSource(const QString &path, int *sourceHost) { - QList mappings = db->getMappingsToHost(hostId()); + QList mappings = database()->getMappingsToHost(hostId()); foreach(const PathMapping &pm, mappings) { -- 2.52.0