Fixed thread leak when a comic has to be destroyed while it is being processed.

This commit is contained in:
Luis Ángel San Martín 2017-09-27 09:38:50 +02:00
parent 618214f667
commit 2b70a5907f
3 changed files with 11 additions and 1 deletions

View File

@ -761,6 +761,8 @@ void Render::createComic(const QString & path)
if(comic!=0)
{
//comic->moveToThread(QApplication::instance()->thread());
comic->invalidate();
comic->disconnect();
comic->deleteLater();
}
@ -817,6 +819,7 @@ void Render::startLoad()
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()));

View File

@ -199,7 +199,12 @@ void Comic::updateBookmarkImage(int index)
//-----------------------------------------------------------------------------
void Comic::setPageLoaded(int page)
{
_loadedPages[page] = true;
_loadedPages[page] = true;
}
void Comic::invalidate()
{
emit invalidated();
}
//-----------------------------------------------------------------------------
QByteArray Comic::getRawPage(int page)

View File

@ -86,8 +86,10 @@ 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);