local server now runs in a separated thread

This commit is contained in:
Luis Ángel San Martín 2013-08-24 23:25:13 +02:00
parent b684b580ed
commit c96950584f
6 changed files with 20 additions and 5 deletions

View File

@ -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;

View File

@ -798,6 +798,7 @@ void Viewer::mouseReleaseEvent ( QMouseEvent * event )
void Viewer::updateFitToWidthRatio(float ratio)
{
Configuration::getConfiguration().setAdjustToWidth(true);
adjustToWidthRatio = ratio;
updateContentSize();
}

View File

@ -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;

View File

@ -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();

View File

@ -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();

View File

@ -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;
};