mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
Added mutex to YACReaderClientConnectionWorker, syncronized access to DB
This commit is contained in:
parent
8800595073
commit
38f934e4c6
@ -11,6 +11,8 @@
|
||||
|
||||
using namespace YACReader;
|
||||
|
||||
QMutex YACReaderClientConnectionWorker::dbMutex;
|
||||
|
||||
YACReaderLocalServer::YACReaderLocalServer(QObject *parent) :
|
||||
QThread(parent)
|
||||
{
|
||||
@ -145,12 +147,14 @@ void YACReaderClientConnectionWorker::run()
|
||||
|
||||
void YACReaderClientConnectionWorker::getComicInfo(quint64 libraryId, ComicDB & comic, QList<ComicDB> & siblings)
|
||||
{
|
||||
QMutexLocker locker(&dbMutex);
|
||||
comic = DBHelper::getComicInfo(DBHelper::getLibrariesNames().at(libraryId), comic.id);
|
||||
siblings = DBHelper::getSiblings(DBHelper::getLibrariesNames().at(libraryId), comic.parentId);
|
||||
}
|
||||
|
||||
void YACReaderClientConnectionWorker::updateComic(quint64 libraryId, ComicDB & comic)
|
||||
{
|
||||
QMutexLocker locker(&dbMutex);
|
||||
DBHelper::update(DBHelper::getLibrariesNames().at(libraryId), comic.info);
|
||||
emit comicUpdated(libraryId, comic);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QThread>
|
||||
#include <QMutex>
|
||||
|
||||
class QLocalServer;
|
||||
class QLocalSocket;
|
||||
@ -35,6 +36,7 @@ public:
|
||||
signals:
|
||||
void comicUpdated(quint64 libraryId, const ComicDB & comic);
|
||||
private:
|
||||
static QMutex dbMutex;
|
||||
void run();
|
||||
|
||||
void getComicInfo(quint64 libraryId, ComicDB & comic, QList<ComicDB> & sibling);
|
||||
|
Loading…
x
Reference in New Issue
Block a user