From 5257dc88d6c2fdc5e543acc384994f60ccd9a2b6 Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Wed, 3 Feb 2021 21:32:44 +0200 Subject: [PATCH 1/6] Library: destroy the temporary thread when deleting finishes finished() signal of both FoldersRemover and ComicsRemover was not connected to their QThread's quit() slot. So the thread kept running after the deletion completed. The QThread's parent is LibraryWindow. Thus LibraryWindow's ~QObject() invokes the QThread's destructor. As a result, when the user exited YACReader Library after deleting at least one folder or comic, it printed the following FATAL message and crashed at exit: "QThread: Destroyed while thread is still running". Extract signal-slot connections between a remover and a QThread into moveAndConnectRemoverToThread() to reduce code duplication. Remove always true (thread != NULL) checks. --- YACReaderLibrary/library_window.cpp | 41 ++++++++++++++--------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index b3edb7618..4cdc4b83d 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -91,6 +91,20 @@ #include #endif +namespace { +template +void moveAndConnectRemoverToThread(Remover *remover, QThread *thread) +{ + Q_ASSERT(remover); + Q_ASSERT(thread); + remover->moveToThread(thread); + QObject::connect(thread, &QThread::started, remover, &Remover::process); + QObject::connect(remover, &Remover::finished, remover, &QObject::deleteLater); + QObject::connect(remover, &Remover::finished, thread, &QThread::quit); + QObject::connect(thread, &QThread::finished, thread, &QObject::deleteLater); +} +} + using namespace YACReader; LibraryWindow::LibraryWindow() @@ -1535,22 +1549,14 @@ void LibraryWindow::deleteSelectedFolder() paths << folderPath; auto remover = new FoldersRemover(indexList, paths); + const auto thread = new QThread(this); + moveAndConnectRemoverToThread(remover, thread); - QThread *thread = NULL; - - thread = new QThread(this); - - remover->moveToThread(thread); - - connect(thread, SIGNAL(started()), remover, SLOT(process())); connect(remover, SIGNAL(remove(QModelIndex)), foldersModel, SLOT(deleteFolder(QModelIndex))); connect(remover, SIGNAL(removeError()), this, SLOT(errorDeletingFolder())); connect(remover, SIGNAL(finished()), navigationController, SLOT(reselectCurrentFolder())); - connect(remover, SIGNAL(finished()), remover, SLOT(deleteLater())); - connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); - if (thread != NULL) - thread->start(); + thread->start(); } } } @@ -2530,15 +2536,11 @@ void LibraryWindow::deleteComicsFromDisk() } auto remover = new ComicsRemover(indexList, paths, comics.at(0).parentId); - QThread *thread = NULL; - - thread = new QThread(this); - - remover->moveToThread(thread); + const auto thread = new QThread(this); + moveAndConnectRemoverToThread(remover, thread); comicsModel->startTransaction(); - connect(thread, SIGNAL(started()), remover, SLOT(process())); connect(remover, SIGNAL(remove(int)), comicsModel, SLOT(remove(int))); connect(remover, SIGNAL(removeError()), this, SLOT(setRemoveError())); connect(remover, SIGNAL(finished()), comicsModel, SLOT(finishTransaction())); @@ -2547,11 +2549,8 @@ void LibraryWindow::deleteComicsFromDisk() connect(remover, SIGNAL(finished()), this, SLOT(checkEmptyFolder())); connect(remover, SIGNAL(finished()), this, SLOT(checkRemoveError())); - connect(remover, SIGNAL(finished()), remover, SLOT(deleteLater())); - connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); - if (thread != NULL) - thread->start(); + thread->start(); } } From aa9dd95d5df1071016ed64753d9d19c5ac916f6f Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Thu, 4 Feb 2021 20:31:26 +0200 Subject: [PATCH 2/6] LibraryWindow: remove a duplicate signal-slot connection QSqlDatabase::commit() in ComicModel::finishTransaction() returned false (failed) when this slot was invoked the second time in a row. --- YACReaderLibrary/library_window.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index 4cdc4b83d..f74d2b274 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -2544,7 +2544,6 @@ void LibraryWindow::deleteComicsFromDisk() connect(remover, SIGNAL(remove(int)), comicsModel, SLOT(remove(int))); connect(remover, SIGNAL(removeError()), this, SLOT(setRemoveError())); connect(remover, SIGNAL(finished()), comicsModel, SLOT(finishTransaction())); - connect(remover, SIGNAL(finished()), comicsModel, SLOT(finishTransaction())); connect(remover, SIGNAL(removedItemsFromFolder(qulonglong)), foldersModel, SLOT(updateFolderChildrenInfo(qulonglong))); connect(remover, SIGNAL(finished()), this, SLOT(checkEmptyFolder())); From af13279c182ebe055245b9f4d7cfeca403697c16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 11 Jun 2021 22:36:33 +0200 Subject: [PATCH 3/6] Fix open comic signal --- YACReaderLibrary/comics_view.h | 2 +- YACReaderLibrary/grid_comics_view.cpp | 2 +- YACReaderLibrary/yacreader_comics_views_manager.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/YACReaderLibrary/comics_view.h b/YACReaderLibrary/comics_view.h index 9b98eee7e..2b4f0551b 100644 --- a/YACReaderLibrary/comics_view.h +++ b/YACReaderLibrary/comics_view.h @@ -38,7 +38,7 @@ public slots: signals: void selected(unsigned int); - void openComic(const ComicDB &comic); + void openComic(); void comicRated(int, QModelIndex); //Context menus diff --git a/YACReaderLibrary/grid_comics_view.cpp b/YACReaderLibrary/grid_comics_view.cpp index b844bfa6a..77bde1576 100644 --- a/YACReaderLibrary/grid_comics_view.cpp +++ b/YACReaderLibrary/grid_comics_view.cpp @@ -398,7 +398,7 @@ void GridComicsView::selectIndex(int index) void GridComicsView::triggerOpenCurrentComic() { - emit openComic(currentComic); + emit openComic(); } void GridComicsView::rate(int index, int rating) diff --git a/YACReaderLibrary/yacreader_comics_views_manager.cpp b/YACReaderLibrary/yacreader_comics_views_manager.cpp index 453018312..fa1a9a6a8 100644 --- a/YACReaderLibrary/yacreader_comics_views_manager.cpp +++ b/YACReaderLibrary/yacreader_comics_views_manager.cpp @@ -146,7 +146,7 @@ void YACReaderComicsViewsManager::doComicsViewConnections() connect(comicsView, SIGNAL(comicRated(int, QModelIndex)), libraryWindow->comicsModel, SLOT(updateRating(int, QModelIndex))); connect(libraryWindow->showHideMarksAction, SIGNAL(toggled(bool)), comicsView, SLOT(setShowMarks(bool))); connect(comicsView, SIGNAL(selected(unsigned int)), libraryWindow, SLOT(openComic())); - connect(comicsView, SIGNAL(openComic(ComicDB)), libraryWindow, SLOT(openComic(ComicDB))); + connect(comicsView, SIGNAL(openComic()), libraryWindow, SLOT(openComic())); connect(libraryWindow->selectAllComicsAction, SIGNAL(triggered()), comicsView, SLOT(selectAll())); From ad036ec6ae68df9398f85409e373176e5b8a7567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Fri, 18 Jun 2021 22:55:08 +0200 Subject: [PATCH 4/6] Include the hashes of the prev/next comics in the comic info when opening a comic in the server --- .../server/controllers/v2/comiccontroller_v2.cpp | 14 ++++++++++---- .../v2/comiccontrollerinreadinglist_v2.cpp | 14 ++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/YACReaderLibrary/server/controllers/v2/comiccontroller_v2.cpp b/YACReaderLibrary/server/controllers/v2/comiccontroller_v2.cpp index e962d6b0a..d78fd8e20 100644 --- a/YACReaderLibrary/server/controllers/v2/comiccontroller_v2.cpp +++ b/YACReaderLibrary/server/controllers/v2/comiccontroller_v2.cpp @@ -105,10 +105,16 @@ void ComicControllerV2::service(HttpRequest &request, HttpResponse &response) } } if (found) { - if (i > 0) - response.write(QString("previousComic:%1\r\n").arg(siblings.at(i - 1)->id).toUtf8()); - if (i < siblings.length() - 1) - response.write(QString("nextComic:%1\r\n").arg(siblings.at(i + 1)->id).toUtf8()); + if (i > 0) { + ComicDB *previousComic = static_cast(siblings.at(i - 1)); + response.write(QString("previousComic:%1\r\n").arg(previousComic->id).toUtf8()); + response.write(QString("previousComicHash:%1\r\n").arg(previousComic->info.hash).toUtf8()); + } + if (i < siblings.length() - 1) { + ComicDB *nextComic = static_cast(siblings.at(i + 1)); + response.write(QString("nextComic:%1\r\n").arg(nextComic->id).toUtf8()); + response.write(QString("nextComicHash:%1\r\n").arg(nextComic->info.hash).toUtf8()); + } } else { //ERROR } diff --git a/YACReaderLibrary/server/controllers/v2/comiccontrollerinreadinglist_v2.cpp b/YACReaderLibrary/server/controllers/v2/comiccontrollerinreadinglist_v2.cpp index bbadf8e04..84b2fda0b 100644 --- a/YACReaderLibrary/server/controllers/v2/comiccontrollerinreadinglist_v2.cpp +++ b/YACReaderLibrary/server/controllers/v2/comiccontrollerinreadinglist_v2.cpp @@ -83,10 +83,16 @@ void ComicControllerInReadingListV2::service(HttpRequest &request, HttpResponse } } if (found) { - if (i > 0) - response.write(QString("previousComic:%1\r\n").arg(siblings.at(i - 1).id).toUtf8()); - if (i < siblings.length() - 1) - response.write(QString("nextComic:%1\r\n").arg(siblings.at(i + 1).id).toUtf8()); + if (i > 0) { + ComicDB previousComic = siblings.at(i - 1); + response.write(QString("previousComic:%1\r\n").arg(previousComic.id).toUtf8()); + response.write(QString("previousComicHash:%1\r\n").arg(previousComic.info.hash).toUtf8()); + } + if (i < siblings.length() - 1) { + ComicDB nextComic = siblings.at(i + 1); + response.write(QString("nextComic:%1\r\n").arg(nextComic.id).toUtf8()); + response.write(QString("nextComicHash:%1\r\n").arg(nextComic.info.hash).toUtf8()); + } } else { //ERROR } From 91c9375dc1266b8267a6b4eb9d334737c2f24a89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sat, 19 Jun 2021 07:24:29 +0200 Subject: [PATCH 5/6] Fix opening a comic from the current/next comic banner in the grid view --- YACReaderLibrary/comics_view.h | 2 +- YACReaderLibrary/grid_comics_view.cpp | 6 +++- YACReaderLibrary/library_window.cpp | 36 +++++++++++-------- YACReaderLibrary/library_window.h | 4 ++- .../yacreader_comics_views_manager.cpp | 2 +- 5 files changed, 31 insertions(+), 19 deletions(-) diff --git a/YACReaderLibrary/comics_view.h b/YACReaderLibrary/comics_view.h index 2b4f0551b..cee4c6abb 100644 --- a/YACReaderLibrary/comics_view.h +++ b/YACReaderLibrary/comics_view.h @@ -38,7 +38,7 @@ public slots: signals: void selected(unsigned int); - void openComic(); + void openComic(const ComicDB &comic, const ComicModel::Mode mode); void comicRated(int, QModelIndex); //Context menus diff --git a/YACReaderLibrary/grid_comics_view.cpp b/YACReaderLibrary/grid_comics_view.cpp index 77bde1576..40140c16f 100644 --- a/YACReaderLibrary/grid_comics_view.cpp +++ b/YACReaderLibrary/grid_comics_view.cpp @@ -398,7 +398,11 @@ void GridComicsView::selectIndex(int index) void GridComicsView::triggerOpenCurrentComic() { - emit openComic(); + if (model == nullptr) { + return; + } + + emit openComic(currentComic, model->getMode()); } void GridComicsView::rate(int index, int rating) diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index e359f8fb0..ae50be94c 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -1840,31 +1840,37 @@ void LibraryWindow::checkEmptyFolder() void LibraryWindow::openComic() { if (!importedCovers) { - auto libraryId = libraries.getId(selectedLibrary->currentText()); auto comic = comicsModel->getComic(comicsViewsManager->comicsView->currentIndex()); auto mode = comicsModel->getMode(); - OpenComicSource::Source source; + openComic(comic, mode); + } +} - if (mode == ComicModel::ReadingList) { - source = OpenComicSource::Source::ReadingList; - } else if (mode == ComicModel::Reading) { - //TODO check where the comic was opened from the last time it was read - source = OpenComicSource::Source::Folder; - } else { - source = OpenComicSource::Source::Folder; - } +void LibraryWindow::openComic(const ComicDB &comic, const ComicModel::Mode mode) +{ + auto libraryId = libraries.getId(selectedLibrary->currentText()); - auto yacreaderFound = YACReader::openComic(comic, libraryId, currentPath(), OpenComicSource { source, comicsModel->getSourceId() }); + OpenComicSource::Source source; - if (!yacreaderFound) { + if (mode == ComicModel::ReadingList) { + source = OpenComicSource::Source::ReadingList; + } else if (mode == ComicModel::Reading) { + //TODO check where the comic was opened from the last time it was read + source = OpenComicSource::Source::Folder; + } else { + source = OpenComicSource::Source::Folder; + } + + auto yacreaderFound = YACReader::openComic(comic, libraryId, currentPath(), OpenComicSource { source, comicsModel->getSourceId() }); + + if (!yacreaderFound) { #ifdef Q_OS_WIN - QMessageBox::critical(this, tr("YACReader not found"), tr("YACReader not found. YACReader should be installed in the same folder as YACReaderLibrary.")); + QMessageBox::critical(this, tr("YACReader not found"), tr("YACReader not found. YACReader should be installed in the same folder as YACReaderLibrary.")); #else - QMessageBox::critical(this, tr("YACReader not found"), tr("YACReader not found. There might be a problem with your YACReader installation.")); + QMessageBox::critical(this, tr("YACReader not found"), tr("YACReader not found. There might be a problem with your YACReader installation.")); #endif - } } } diff --git a/YACReaderLibrary/library_window.h b/YACReaderLibrary/library_window.h index 7b0a14e88..2db2c7c46 100644 --- a/YACReaderLibrary/library_window.h +++ b/YACReaderLibrary/library_window.h @@ -13,6 +13,8 @@ #include "comic_query_result_processor.h" #include "folder_query_result_processor.h" +#include "comic_model.h" + #include #include @@ -77,7 +79,6 @@ class YACReaderHistoryController; class EmptyLabelWidget; class EmptySpecialListWidget; class EmptyReadingListWidget; -class YACReaderComicsViewsManager; namespace YACReader { class TrayIconController; @@ -315,6 +316,7 @@ public slots: void selectSubfolder(const QModelIndex &mi, int child); void checkEmptyFolder(); void openComic(); + void openComic(const ComicDB &comic, const ComicModel::Mode mode); void createLibrary(); void create(QString source, QString dest, QString name); void showAddLibrary(); diff --git a/YACReaderLibrary/yacreader_comics_views_manager.cpp b/YACReaderLibrary/yacreader_comics_views_manager.cpp index fa1a9a6a8..585a6533f 100644 --- a/YACReaderLibrary/yacreader_comics_views_manager.cpp +++ b/YACReaderLibrary/yacreader_comics_views_manager.cpp @@ -146,7 +146,7 @@ void YACReaderComicsViewsManager::doComicsViewConnections() connect(comicsView, SIGNAL(comicRated(int, QModelIndex)), libraryWindow->comicsModel, SLOT(updateRating(int, QModelIndex))); connect(libraryWindow->showHideMarksAction, SIGNAL(toggled(bool)), comicsView, SLOT(setShowMarks(bool))); connect(comicsView, SIGNAL(selected(unsigned int)), libraryWindow, SLOT(openComic())); - connect(comicsView, SIGNAL(openComic()), libraryWindow, SLOT(openComic())); + connect(comicsView, SIGNAL(openComic(const ComicDB &, const ComicModel::Mode)), libraryWindow, SLOT(openComic(const ComicDB &, const ComicModel::Mode))); connect(libraryWindow->selectAllComicsAction, SIGNAL(triggered()), comicsView, SLOT(selectAll())); From 891546b42348c9e4e3edbd216a20134a5bf2a080 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Sat, 19 Jun 2021 18:13:01 +0200 Subject: [PATCH 6/6] 9.8.2 release --- CHANGELOG.md | 7 +++++++ common/yacreader_global.h | 2 +- custom_widgets/whats_new_dialog.cpp | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a889d976..e3a496af8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ Version counting is based on semantic versioning (Major.Feature.Patch) ## WIP +## 9.8.2 +### YACReaderLibrary +* Fix opening comics from the continue reading banner. +* Make available next/prev comic covers in the iOS app while reading. (ios app 3.16.1 needed) +### Server +* Make available next/prev comic covers in the iOS app while reading. (ios app 3.16.1 needed) + ## 9.8.1 ### YACReaderLibrary * Fix "reading lists" reading order on YACReader. Now YACReader is able to open the right comics in the right order. diff --git a/common/yacreader_global.h b/common/yacreader_global.h index 8b2a0b214..d01c9af97 100644 --- a/common/yacreader_global.h +++ b/common/yacreader_global.h @@ -4,7 +4,7 @@ #include #include -#define VERSION "9.8.1" +#define VERSION "9.8.2" #define REMOTE_BROWSE_PERFORMANCE_WORKAROUND "REMOTE_BROWSE_PERFORMANCE_WORKAROUND" diff --git a/custom_widgets/whats_new_dialog.cpp b/custom_widgets/whats_new_dialog.cpp index 90dad39ff..bc31826b2 100644 --- a/custom_widgets/whats_new_dialog.cpp +++ b/custom_widgets/whats_new_dialog.cpp @@ -59,10 +59,13 @@ YACReader::WhatsNewDialog::WhatsNewDialog(QWidget *parent) " • Support for HTML in comic synopsis, this fixes the synopsis when it comes from Comic Vine with HTML tags.
" " • Improve keyboard navigation in Comic Vine dialog. Enter will trigger next or search and Backspace will go back to the previous section.
" " • Fixed opening comics from readings lists, now YACReader will follow the right order and it will open the right comics in the list. (new in 9.8.1)
" + " • Fixed opening comics from the continue reading banner. (new in 9.8.2)
" + " • Make available next/prev comic covers in the iOS app while reading. (new in 9.8.2)
" "
" "Server
" " • New `manga` field is sent to YACReader for iOS, so comics tagged as manga will be recognized as such when reading remotely or importing comics.
" " • Fixed opening comics from readings lists, now YACReader for iOS will follow the right order and it will open the right comics in the list, it needs YACReader for iOS 3.15.0 or newer. (new in 9.8.1).
" + " • Make available next/prev comic covers in the iOS app while reading. (new in 9.8.2)
" "
" "I hope you enjoy the new update. Please, if you like YACReader consider to become a patron in Patreon or donate some money using Pay-Pal and help keeping the project alive. Remember that there is an iOS version available in the Apple App Store."); QFont textLabelFont("Arial", 15, QFont::Light);