some bugs fixed in local server/client communication

This commit is contained in:
Luis Ángel San Martín
2013-08-24 20:13:38 +02:00
parent 8ae63e562a
commit b684b580ed
7 changed files with 95 additions and 81 deletions

View File

@ -204,7 +204,7 @@ void MainWindowViewer::openFromArgv()
}
else if(QCoreApplication::argc() == 4)
{
isClient = true;
QString pathFile = QCoreApplication::arguments().at(1);
currentDirectory = pathFile;
quint64 comicId = QCoreApplication::arguments().at(2).toULongLong();
@ -217,10 +217,11 @@ void MainWindowViewer::openFromArgv()
if(client.requestComicInfo(libraryId,currentComicDB,siblingComics))
{
isClient = true;
open(pathFile+currentComicDB.path,currentComicDB,siblingComics);
}
else
{/*error*/}
{isClient = false;/*error*/}
optionsDialog->setFilters(currentComicDB.info.brightness, currentComicDB.info.contrast, currentComicDB.info.gamma);
}

View File

@ -854,6 +854,8 @@ int Viewer::getCurrentPageNumber()
void Viewer::updateComic(ComicDB & comic)
{
if(render->hasLoadedComic())
{
//set currentPage
comic.info.currentPage = render->getIndex()+1;
//set bookmarks
@ -879,6 +881,7 @@ void Viewer::updateComic(ComicDB & comic)
comic.info.contrast = contrast;
if(gamma != 100 || comic.info.gamma!=-1)
comic.info.gamma = gamma;
}
}

View File

@ -51,12 +51,12 @@ bool YACReaderLocalClient::requestComicInfo(quint64 libraryId, ComicDB & comic,
//QByteArray data;
tries = 0;
while(localSocket->bytesAvailable() < sizeof(quint16) && tries < 200)
while(localSocket->bytesAvailable() < sizeof(quint16) && tries < 10)
{
localSocket->waitForReadyRead(10);
localSocket->waitForReadyRead(100);
tries++;
}
if(tries == 200)
if(tries == 20)
return false;
QDataStream sizeStream(localSocket->read(sizeof(quint16)));
sizeStream.setVersion(QDataStream::Qt_4_8);
@ -64,12 +64,12 @@ bool YACReaderLocalClient::requestComicInfo(quint64 libraryId, ComicDB & comic,
sizeStream >> totalSize;
tries = 0;
while(localSocket->bytesAvailable() < totalSize && tries < 200 )
while(localSocket->bytesAvailable() < totalSize && tries < 10 )
{
localSocket->waitForReadyRead(10);
localSocket->waitForReadyRead(100);
tries++;
}
if(tries == 200)
if(tries == 20)
return false;
QDataStream dataStream(localSocket->read(totalSize));
dataStream >> comic;