]> Some of my projects - localmylist.git/commitdiff
Return the right database for the current thread.
authorAPTX <marek321@gmail.com>
Thu, 18 Apr 2013 01:24:51 +0000 (03:24 +0200)
committerAPTX <marek321@gmail.com>
Thu, 18 Apr 2013 01:24:51 +0000 (03:24 +0200)
localmylist/mylist.cpp

index b4636bffc8415f778b5da2747a7cfc8d2ac53786..f794c3de0c979872a7904bee11654febd4f0d7c1 100644 (file)
@@ -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<PathMapping> mappings = db->getMappingsToHost(hostId());
+       QList<PathMapping> 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<PathMapping> mappings = db->getMappingsToHost(hostId());
+       QList<PathMapping> mappings = database()->getMappingsToHost(hostId());
 
        foreach(const PathMapping &pm, mappings)
        {