From: APTX Date: Thu, 18 Apr 2013 01:24:51 +0000 (+0200) Subject: Return the right database for the current thread. X-Git-Url: https://gitweb.aptx.org/?a=commitdiff_plain;h=57336afea191f0aa3318ee4d13365b5b0d3f9c51;p=localmylist.git Return the right database for the current thread. --- 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) {