From 92cf54980c6ef40a11cf9ac4a0b7a28f7044b83a Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Mon, 20 May 2019 21:47:44 +0300 Subject: [PATCH 1/3] Library: eliminate QPainter warnings There were many run-time warnings in YACReaderLibrary built in Debug mode with hardware acceleration disabled and with ClassicComicsView as the active comics view: QWidget::paintEngine: Should no longer be called QPainter::begin: Paint device returned engine == 0, type: 1 The ComicFlowWidgetSW::paintEvent() implementation now corresponds to ComicFlowWidgetGL::paintEvent(), which has been fixed earlier. QWidget::repaint() calls paintEvent() immediately. PictureFlow::paintEvent() calls d->renderer->paint(). So the d->renderer->paint() call in PictureFlow::updateMarks() was redundant. --- YACReaderLibrary/comic_flow_widget.cpp | 2 +- common/pictureflow.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/YACReaderLibrary/comic_flow_widget.cpp b/YACReaderLibrary/comic_flow_widget.cpp index e96dc684..6c114a54 100644 --- a/YACReaderLibrary/comic_flow_widget.cpp +++ b/YACReaderLibrary/comic_flow_widget.cpp @@ -105,7 +105,7 @@ void ComicFlowWidgetSW::keyPressEvent(QKeyEvent* event) } void ComicFlowWidgetSW::paintEvent(QPaintEvent *event) { - flow->paintEvent(event); + ComicFlowWidget::paintEvent(event); } void ComicFlowWidgetSW::mousePressEvent(QMouseEvent* event) { diff --git a/common/pictureflow.cpp b/common/pictureflow.cpp index edb5149c..ac99f9a0 100644 --- a/common/pictureflow.cpp +++ b/common/pictureflow.cpp @@ -1421,7 +1421,6 @@ void PictureFlow::markSlide(int index, YACReaderComicReadStatus readStatus) void PictureFlow::updateMarks() { d->renderer->init(); - d->renderer->paint(); repaint(); } From c1810b9e5459938cb54f829c43f046c8b2449ad4 Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Fri, 24 May 2019 14:43:40 +0300 Subject: [PATCH 2/3] Library: do not needlessly retrieve all comics from the DB The siblings variable is unused. So the ComicModel::getAllComics() call is redundant unless there is some unobvious side effect (I hope not). --- YACReaderLibrary/library_window.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index 182894c2..8dc5892b 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -1798,8 +1798,6 @@ void LibraryWindow::checkEmptyFolder() void LibraryWindow::openComic(const ComicDB &comic) { if(!importedCovers) { - QList siblings = comicsModel->getAllComics(); - //TODO generate IDS for libraries... quint64 libraryId = libraries.getId(selectedLibrary->currentText()); bool yacreaderFound = false; From 12aabf79603a58d13678f0576d15ad2a57fa46e3 Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Fri, 24 May 2019 14:49:49 +0300 Subject: [PATCH 3/3] Reader: fix thread safety bugs in PageLoader --- YACReader/goto_flow.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/YACReader/goto_flow.cpp b/YACReader/goto_flow.cpp index 167074de..57cb718a 100644 --- a/YACReader/goto_flow.cpp +++ b/YACReader/goto_flow.cpp @@ -260,6 +260,8 @@ PageLoader::PageLoader(QMutex * m): PageLoader::~PageLoader() { + //TODO this destructor never runs. If it is ever called, it will hang, because + //the implementation is broken due to the absolutely endless loop in run(). mutex->lock(); condition.wakeOne(); mutex->unlock(); @@ -284,9 +286,11 @@ void PageLoader::generate(int index, QSize size,const QByteArray & rImage) start(); else { + mutex->lock(); // already running, wake up whenever ready restart = true; condition.wakeOne(); + mutex->unlock(); } } @@ -314,7 +318,7 @@ void PageLoader::run() // put to sleep mutex->lock(); - if (!this->restart) + while (!this->restart) condition.wait(mutex); restart = false; mutex->unlock();