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