From 2b70a5907f37b45d3e0f4562ababf2a6bc030c66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Wed, 27 Sep 2017 09:38:50 +0200 Subject: [PATCH] Fixed thread leak when a comic has to be destroyed while it is being processed. --- YACReader/render.cpp | 3 +++ common/comic.cpp | 7 ++++++- common/comic.h | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/YACReader/render.cpp b/YACReader/render.cpp index 7ccafdc9..9557ff28 100644 --- a/YACReader/render.cpp +++ b/YACReader/render.cpp @@ -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())); diff --git a/common/comic.cpp b/common/comic.cpp index 08456645..eb8afaaf 100644 --- a/common/comic.cpp +++ b/common/comic.cpp @@ -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) diff --git a/common/comic.h b/common/comic.h index ba79f7f4..6b6e183e 100644 --- a/common/comic.h +++ b/common/comic.h @@ -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);