mirror of
https://github.com/YACReader/yacreader
synced 2025-07-18 04:54:29 -04:00
Merged in selmf/yacreader/small-fixes-9.0 (pull request #52)
Small fixes 9.0:
This commit is contained in:
@ -761,6 +761,8 @@ void Render::createComic(const QString & path)
|
||||
if(comic!=0)
|
||||
{
|
||||
//comic->moveToThread(QApplication::instance()->thread());
|
||||
comic->invalidate();
|
||||
|
||||
comic->disconnect();
|
||||
comic->deleteLater();
|
||||
}
|
||||
@ -777,19 +779,19 @@ void Render::createComic(const QString & path)
|
||||
|
||||
previousIndex = currentIndex = 0;
|
||||
|
||||
connect(comic,SIGNAL(errorOpening()),this,SIGNAL(errorOpening()));
|
||||
connect(comic,SIGNAL(errorOpening(QString)),this,SIGNAL(errorOpening(QString)));
|
||||
connect(comic,SIGNAL(crcErrorFound(QString)),this,SIGNAL(crcError(QString)));
|
||||
connect(comic,SIGNAL(errorOpening()),this,SLOT(reset()));
|
||||
connect(comic,SIGNAL(imageLoaded(int)),this,SIGNAL(imageLoaded(int)));
|
||||
connect(comic,SIGNAL(imageLoaded(int)),this,SLOT(pageRawDataReady(int)));
|
||||
connect(comic,SIGNAL(openAt(int)),this,SLOT(renderAt(int)));
|
||||
connect(comic,SIGNAL(numPages(unsigned int)),this,SIGNAL(numPages(unsigned int)));
|
||||
connect(comic,SIGNAL(numPages(unsigned int)),this,SLOT(setNumPages(unsigned int)));
|
||||
connect(comic,SIGNAL(imageLoaded(int,QByteArray)),this,SIGNAL(imageLoaded(int,QByteArray)));
|
||||
connect(comic,SIGNAL(isBookmark(bool)),this,SIGNAL(currentPageIsBookmark(bool)));
|
||||
connect(comic,SIGNAL(errorOpening()),this,SIGNAL(errorOpening()), Qt::QueuedConnection);
|
||||
connect(comic,SIGNAL(errorOpening(QString)),this,SIGNAL(errorOpening(QString)), Qt::QueuedConnection);
|
||||
connect(comic,SIGNAL(crcErrorFound(QString)),this,SIGNAL(crcError(QString)), Qt::QueuedConnection);
|
||||
connect(comic,SIGNAL(errorOpening()),this,SLOT(reset()), Qt::QueuedConnection);
|
||||
connect(comic,SIGNAL(imageLoaded(int)),this,SIGNAL(imageLoaded(int)), Qt::QueuedConnection);
|
||||
connect(comic,SIGNAL(imageLoaded(int)),this,SLOT(pageRawDataReady(int)), Qt::QueuedConnection);
|
||||
connect(comic,SIGNAL(openAt(int)),this,SLOT(renderAt(int)), Qt::QueuedConnection);
|
||||
connect(comic,SIGNAL(numPages(unsigned int)),this,SIGNAL(numPages(unsigned int)), Qt::QueuedConnection);
|
||||
connect(comic,SIGNAL(numPages(unsigned int)),this,SLOT(setNumPages(unsigned int)), Qt::QueuedConnection);
|
||||
connect(comic,SIGNAL(imageLoaded(int,QByteArray)),this,SIGNAL(imageLoaded(int,QByteArray)), Qt::QueuedConnection);
|
||||
connect(comic,SIGNAL(isBookmark(bool)),this,SIGNAL(currentPageIsBookmark(bool)), Qt::QueuedConnection);
|
||||
|
||||
connect(comic,SIGNAL(bookmarksUpdated()),this,SIGNAL(bookmarksUpdated()));
|
||||
connect(comic,SIGNAL(bookmarksUpdated()),this,SIGNAL(bookmarksUpdated()), Qt::QueuedConnection);
|
||||
|
||||
//connect(comic,SIGNAL(isLast()),this,SIGNAL(isLast()));
|
||||
//connect(comic,SIGNAL(isCover()),this,SIGNAL(isCover()));
|
||||
@ -807,19 +809,21 @@ void Render::loadComic(const QString & path, int atPage)
|
||||
|
||||
void Render::startLoad()
|
||||
{
|
||||
QThread * thread = NULL;
|
||||
QThread * thread = nullptr;
|
||||
|
||||
thread = new QThread();
|
||||
|
||||
comic->moveToThread(thread);
|
||||
|
||||
connect(comic, SIGNAL(errorOpening()), thread, SLOT(quit()));
|
||||
connect(comic, SIGNAL(errorOpening(QString)), thread, SLOT(quit()));
|
||||
connect(comic, SIGNAL(imagesLoaded()), thread, SLOT(quit()));
|
||||
connect(comic, SIGNAL(errorOpening()), thread, SLOT(quit()), Qt::QueuedConnection);
|
||||
connect(comic, SIGNAL(errorOpening(QString)), thread, SLOT(quit()), Qt::QueuedConnection);
|
||||
connect(comic, SIGNAL(imagesLoaded()), thread, SLOT(quit()), Qt::QueuedConnection);
|
||||
connect(comic, SIGNAL(destroyed()), thread, SLOT(quit()), Qt::QueuedConnection);
|
||||
connect(comic, SIGNAL(invalidated()), thread, SLOT(quit()), Qt::QueuedConnection);
|
||||
connect(thread, SIGNAL(started()), comic, SLOT(process()));
|
||||
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
||||
|
||||
if(thread != NULL)
|
||||
if(thread != nullptr)
|
||||
thread->start();
|
||||
|
||||
invalidate();
|
||||
|
@ -243,6 +243,9 @@ void DBHelper::update(qulonglong libraryId, ComicInfo & comicInfo)
|
||||
|
||||
void DBHelper::update(ComicInfo * comicInfo, QSqlDatabase & db)
|
||||
{
|
||||
if(comicInfo == nullptr)
|
||||
return;
|
||||
|
||||
QSqlQuery updateComicInfo(db);
|
||||
updateComicInfo.prepare("UPDATE comic_info SET "
|
||||
"title = :title,"
|
||||
@ -385,7 +388,7 @@ void DBHelper::updateProgress(qulonglong libraryId, const ComicInfo &comicInfo)
|
||||
comic.info.currentPage = comicInfo.currentPage;
|
||||
comic.info.hasBeenOpened = true;
|
||||
|
||||
DBHelper::update(&comic.info,db);
|
||||
DBHelper::updateReadingRemoteProgress(comic.info,db);
|
||||
|
||||
db.close();
|
||||
QSqlDatabase::removeDatabase(libraryPath);
|
||||
@ -407,6 +410,8 @@ void DBHelper::updateReadingRemoteProgress(const ComicInfo &comicInfo, QSqlDatab
|
||||
updateComicInfo.bindValue(":id", comicInfo.id);
|
||||
updateComicInfo.bindValue(":rating", comicInfo.rating);
|
||||
updateComicInfo.exec();
|
||||
|
||||
updateComicInfo.clear();
|
||||
}
|
||||
|
||||
|
||||
|
@ -244,6 +244,7 @@ void HttpSession::dismissCurrentComic()
|
||||
{
|
||||
if(dataPtr->yacreaderSessionData.comic != 0)
|
||||
{
|
||||
dataPtr->yacreaderSessionData.comic->invalidate();
|
||||
dataPtr->yacreaderSessionData.comic->deleteLater();
|
||||
dataPtr->yacreaderSessionData.comic = 0;
|
||||
}
|
||||
@ -283,6 +284,7 @@ void HttpSession::dismissCurrentRemoteComic()
|
||||
{
|
||||
if(dataPtr->yacreaderSessionData.remoteComic != 0)
|
||||
{
|
||||
dataPtr->yacreaderSessionData.remoteComic->invalidate();
|
||||
dataPtr->yacreaderSessionData.remoteComic->deleteLater();
|
||||
dataPtr->yacreaderSessionData.remoteComic = 0;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ const QStringList Comic::literalComicExtensions = LiteralComicArchiveExtensions;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
Comic::Comic()
|
||||
:_pages(),_index(0),_path(),_loaded(false),bm(new Bookmarks()),_loadedPages(),_isPDF(false)
|
||||
:_pages(),_index(0),_path(),_loaded(false),bm(new Bookmarks()),_loadedPages(),_isPDF(false),_invalidated(false)
|
||||
{
|
||||
setup();
|
||||
}
|
||||
@ -57,6 +57,7 @@ Comic::Comic(const QString & pathFile, int atPage )
|
||||
//-----------------------------------------------------------------------------
|
||||
Comic::~Comic()
|
||||
{
|
||||
emit destroyed();
|
||||
delete bm;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -200,6 +201,12 @@ void Comic::setPageLoaded(int page)
|
||||
{
|
||||
_loadedPages[page] = true;
|
||||
}
|
||||
|
||||
void Comic::invalidate()
|
||||
{
|
||||
_invalidated = true;
|
||||
emit invalidated();
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
QByteArray Comic::getRawPage(int page)
|
||||
{
|
||||
@ -585,10 +592,20 @@ void FileComic::process()
|
||||
|
||||
for(int i = sectionIndex; i<sections.count() ; i++)
|
||||
{
|
||||
if(_invalidated)
|
||||
{
|
||||
moveToThread(QCoreApplication::instance()->thread());
|
||||
return;
|
||||
}
|
||||
archive.getAllData(sections.at(i),this);
|
||||
}
|
||||
for(int i = 0; i<sectionIndex; i++)
|
||||
{
|
||||
if(_invalidated)
|
||||
{
|
||||
moveToThread(QCoreApplication::instance()->thread());
|
||||
return;
|
||||
}
|
||||
archive.getAllData(sections.at(i),this);
|
||||
}
|
||||
//archive.getAllData(QVector<quint32>(),this);
|
||||
@ -688,6 +705,12 @@ void FolderComic::process()
|
||||
int i=_firstPage;
|
||||
while(count<nPages)
|
||||
{
|
||||
if(_invalidated)
|
||||
{
|
||||
moveToThread(QCoreApplication::instance()->thread());
|
||||
return;
|
||||
}
|
||||
|
||||
QFile f(list.at(i).absoluteFilePath());
|
||||
f.open(QIODevice::ReadOnly);
|
||||
_pages[i]=f.readAll();
|
||||
@ -843,10 +866,23 @@ void PDFComic::process()
|
||||
int buffered_index = _index;
|
||||
for(int i=buffered_index;i<nPages;i++)
|
||||
{
|
||||
if(_invalidated)
|
||||
{
|
||||
delete pdfComic;
|
||||
moveToThread(QCoreApplication::instance()->thread());
|
||||
return;
|
||||
}
|
||||
|
||||
renderPage(i);
|
||||
}
|
||||
for(int i=0;i<buffered_index;i++)
|
||||
{
|
||||
if(_invalidated)
|
||||
{
|
||||
delete pdfComic;
|
||||
moveToThread(QCoreApplication::instance()->thread());
|
||||
return;
|
||||
}
|
||||
renderPage(i);
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,8 @@ class Comic : public QObject
|
||||
|
||||
bool _isPDF;
|
||||
|
||||
bool _invalidated;
|
||||
|
||||
public:
|
||||
|
||||
static const QStringList imageExtensions;
|
||||
@ -79,7 +81,6 @@ class Comic : public QObject
|
||||
static QList<QString> findValidComicFilesInFolder(const QString &path);
|
||||
|
||||
public slots:
|
||||
|
||||
void loadFinished();
|
||||
void setBookmark();
|
||||
void removeBookmark();
|
||||
@ -87,9 +88,11 @@ class Comic : public QObject
|
||||
void checkIsBookmark(int index);
|
||||
void updateBookmarkImage(int);
|
||||
void setPageLoaded(int page);
|
||||
void invalidate();
|
||||
|
||||
signals:
|
||||
|
||||
void invalidated();
|
||||
void destroyed();
|
||||
void imagesLoaded();
|
||||
void imageLoaded(int index);
|
||||
void imageLoaded(int index,const QByteArray & image);
|
||||
|
Reference in New Issue
Block a user