mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
local server now runs in a separated thread
This commit is contained in:
parent
b684b580ed
commit
c96950584f
@ -214,7 +214,12 @@ void MainWindowViewer::openFromArgv()
|
|||||||
|
|
||||||
currentComicDB.id = comicId;
|
currentComicDB.id = comicId;
|
||||||
YACReaderLocalClient client;
|
YACReaderLocalClient client;
|
||||||
|
/*int tries = 0;
|
||||||
|
bool success = false;
|
||||||
|
while(!(success = client.requestComicInfo(libraryId,currentComicDB,siblingComics)) && tries < 3)
|
||||||
|
{
|
||||||
|
tries++;
|
||||||
|
}*/
|
||||||
if(client.requestComicInfo(libraryId,currentComicDB,siblingComics))
|
if(client.requestComicInfo(libraryId,currentComicDB,siblingComics))
|
||||||
{
|
{
|
||||||
isClient = true;
|
isClient = true;
|
||||||
|
@ -798,6 +798,7 @@ void Viewer::mouseReleaseEvent ( QMouseEvent * event )
|
|||||||
|
|
||||||
void Viewer::updateFitToWidthRatio(float ratio)
|
void Viewer::updateFitToWidthRatio(float ratio)
|
||||||
{
|
{
|
||||||
|
Configuration::getConfiguration().setAdjustToWidth(true);
|
||||||
adjustToWidthRatio = ratio;
|
adjustToWidthRatio = ratio;
|
||||||
updateContentSize();
|
updateContentSize();
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ bool YACReaderLocalClient::requestComicInfo(quint64 libraryId, ComicDB & comic,
|
|||||||
localSocket->waitForReadyRead(100);
|
localSocket->waitForReadyRead(100);
|
||||||
tries++;
|
tries++;
|
||||||
}
|
}
|
||||||
if(tries == 20)
|
if(tries == 10)
|
||||||
return false;
|
return false;
|
||||||
QDataStream sizeStream(localSocket->read(sizeof(quint16)));
|
QDataStream sizeStream(localSocket->read(sizeof(quint16)));
|
||||||
sizeStream.setVersion(QDataStream::Qt_4_8);
|
sizeStream.setVersion(QDataStream::Qt_4_8);
|
||||||
@ -69,7 +69,7 @@ bool YACReaderLocalClient::requestComicInfo(quint64 libraryId, ComicDB & comic,
|
|||||||
localSocket->waitForReadyRead(100);
|
localSocket->waitForReadyRead(100);
|
||||||
tries++;
|
tries++;
|
||||||
}
|
}
|
||||||
if(tries == 20)
|
if(tries == 10)
|
||||||
return false;
|
return false;
|
||||||
QDataStream dataStream(localSocket->read(totalSize));
|
QDataStream dataStream(localSocket->read(totalSize));
|
||||||
dataStream >> comic;
|
dataStream >> comic;
|
||||||
|
@ -52,6 +52,8 @@ int main( int argc, char ** argv )
|
|||||||
LibraryWindow * mw = new LibraryWindow();
|
LibraryWindow * mw = new LibraryWindow();
|
||||||
|
|
||||||
mw->connect(localServer,SIGNAL(comicUpdated(quint64, const ComicDB &)),mw,SLOT(updateComicsView(quint64, const ComicDB &)));
|
mw->connect(localServer,SIGNAL(comicUpdated(quint64, const ComicDB &)),mw,SLOT(updateComicsView(quint64, const ComicDB &)));
|
||||||
|
|
||||||
|
localServer->start();
|
||||||
//connections to localServer
|
//connections to localServer
|
||||||
|
|
||||||
mw->show();
|
mw->show();
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
using namespace YACReader;
|
using namespace YACReader;
|
||||||
|
|
||||||
YACReaderLocalServer::YACReaderLocalServer(QObject *parent) :
|
YACReaderLocalServer::YACReaderLocalServer(QObject *parent) :
|
||||||
QObject(parent)
|
QThread(parent)
|
||||||
{
|
{
|
||||||
localServer = new QLocalServer(this);
|
localServer = new QLocalServer(this);
|
||||||
if (!localServer->listen(YACREADERLIBRARY_GUID)) {
|
if (!localServer->listen(YACREADERLIBRARY_GUID)) {
|
||||||
@ -27,6 +27,12 @@ bool YACReaderLocalServer::isListening()
|
|||||||
return localServer->isListening();
|
return localServer->isListening();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void YACReaderLocalServer::run()
|
||||||
|
{
|
||||||
|
while(1)
|
||||||
|
exec();
|
||||||
|
}
|
||||||
|
|
||||||
void YACReaderLocalServer::sendResponse()
|
void YACReaderLocalServer::sendResponse()
|
||||||
{
|
{
|
||||||
QLocalSocket *clientConnection = localServer->nextPendingConnection();
|
QLocalSocket *clientConnection = localServer->nextPendingConnection();
|
||||||
|
@ -8,7 +8,7 @@ class QLocalServer;
|
|||||||
class QLocalSocket;
|
class QLocalSocket;
|
||||||
class ComicDB;
|
class ComicDB;
|
||||||
|
|
||||||
class YACReaderLocalServer : public QObject
|
class YACReaderLocalServer : public QThread
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@ -21,6 +21,7 @@ public slots:
|
|||||||
void sendResponse();
|
void sendResponse();
|
||||||
static bool isRunning();
|
static bool isRunning();
|
||||||
private:
|
private:
|
||||||
|
void run();
|
||||||
QLocalServer * localServer;
|
QLocalServer * localServer;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user