Skip to content

Commit

Permalink
Merge pull request #366 from YACReader/develop
Browse files Browse the repository at this point in the history
9.11
  • Loading branch information
luisangelsm committed Jan 7, 2023
2 parents 6cc92a2 + 49ef617 commit fa3e5ea
Show file tree
Hide file tree
Showing 31 changed files with 1,310 additions and 1,266 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,22 @@

Version counting is based on semantic versioning (Major.Feature.Patch)

## WIP

### YACReader
* Fix segfault (or worse) when exiting YACReader while processing a comic.
* Fix last read page calculation in double page mode.

### YACReaderLibrary
* Fix drag&drop in the comics grid view.
* Detect back/forward mouse buttons to move back and forward through the browsing history.
* Fix crash when disabling the server.

### All apps
* Run logger in a dedicated thread to avoid segfaults at application shutdown
* Add support for poppler-qt6 pdf backend
* Remove image allocation limit.

## 9.10

### YACReader
Expand Down
19 changes: 2 additions & 17 deletions YACReader/YACReader.pro
Expand Up @@ -214,28 +214,16 @@ win32 {
$(COPY) $$shell_path($${SOURCE_QM_DIR}) $$shell_path($${DEPLOYMENT_OUT_QM_DIR})
} else {
LRELEASE_DIR = ../release/languages/
QM_FILES_INSTALL_PATH = $$DATADIR/yacreader/languages
}

unix:!macx {
# set install prefix if it's empty
isEmpty(PREFIX) {
PREFIX = /usr
}
isEmpty(BINDIR) {
BINDIR = $$PREFIX/bin
}
isEmpty(LIBDIR) {
LIBDIR = $$PREFIX/lib
}
isEmpty(DATADIR) {
DATADIR = $$PREFIX/share
}

DEFINES += "LIBDIR=\\\"$$LIBDIR\\\"" "DATADIR=\\\"$$DATADIR\\\""

#MAKE INSTALL

INSTALLS += bin docs icon desktop translation manpage
INSTALLS += bin docs icon desktop manpage

bin.path = $$BINDIR
isEmpty(DESTDIR) {
Expand All @@ -256,9 +244,6 @@ icon.files = ../YACReader.svg
desktop.path = $$DATADIR/applications
desktop.files = ../YACReader.desktop

translation.path = $$DATADIR/yacreader/languages
translation.files = ../release/languages/yacreader_*

manpage.path = $$DATADIR/man/man1
manpage.files = ../YACReader.1

Expand Down
5 changes: 5 additions & 0 deletions YACReader/main.cpp
Expand Up @@ -2,6 +2,7 @@
#include <QDir>
#include <QTranslator>
#include <QCommandLineParser>
#include <QImageReader>

#include "main_window_viewer.h"
#include "configuration.h"
Expand Down Expand Up @@ -97,6 +98,10 @@ int main(int argc, char *argv[])
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QImageReader::setAllocationLimit(0);
#endif

#if defined(_MSC_VER) && defined(_DEBUG)
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif
Expand Down
23 changes: 13 additions & 10 deletions YACReader/render.cpp
Expand Up @@ -382,20 +382,23 @@ Render::Render()

Render::~Render()
{
if (comic != nullptr) {
comic->moveToThread(QApplication::instance()->thread());
comic->deleteLater();
}

foreach (PageRender *pr, pageRenders)
if (pr != nullptr) {
if (pr->wait())
delete pr;
for (auto *pr : pageRenders) {
if (pr != nullptr && pr->wait()) {
delete pr;
}
}

// TODO move to share_ptr
foreach (ImageFilter *filter, filters)
for (auto *filter : filters) {
delete filter;
}

if (comic != nullptr) {
comic->invalidate();
comic->deleteLater();
comic->thread()->quit();
comic->thread()->wait();
}
}
// Este método se encarga de forzar el renderizado de las páginas.
// Actualiza el buffer según es necesario.
Expand Down
4 changes: 3 additions & 1 deletion YACReader/viewer.cpp
Expand Up @@ -1128,7 +1128,9 @@ void Viewer::updateComic(ComicDB &comic)
if (!doublePage || (doublePage && render->currentPageIsDoublePage() == false)) {
comic.info.currentPage = render->getIndex() + 1;
} else {
if (!(render->getIndex() + 1 == comic.info.currentPage || render->getIndex() + 2 == comic.info.currentPage)) {
if (doublePage && render->currentPageIsDoublePage() && (render->getIndex() + 2 >= render->numPages())) {
comic.info.currentPage = std::min(render->numPages(), render->getIndex() + 2);
} else {
comic.info.currentPage = std::min(render->numPages(), render->getIndex() + 1);
}
}
Expand Down
19 changes: 2 additions & 17 deletions YACReaderLibrary/YACReaderLibrary.pro
Expand Up @@ -307,6 +307,7 @@ win32 {
$(COPY) $$shell_path($${SOURCE_QM_DIR}) $$shell_path($${DEPLOYMENT_OUT_QM_DIR})
} else {
LRELEASE_DIR = ../release/languages/
QM_FILES_INSTALL_PATH = $$DATADIR/yacreader/languages
}

#QML/GridView
Expand All @@ -328,24 +329,11 @@ unix:!macx:RESOURCES += qml_win.qrc
macx:RESOURCES += qml_osx.qrc

unix:!macx {
#set install prefix if it's empty
isEmpty(PREFIX) {
PREFIX = /usr
}
isEmpty(BINDIR) {
BINDIR = $$PREFIX/bin
}
isEmpty(LIBDIR) {
LIBDIR = $$PREFIX/lib
}
isEmpty(DATADIR) {
DATADIR = $$PREFIX/share
}

DEFINES += "LIBDIR=\\\"$$LIBDIR\\\"" "DATADIR=\\\"$$DATADIR\\\"" "BINDIR=\\\"$$BINDIR\\\""

#MAKE INSTALL
INSTALLS += bin icon desktop server translation manpage
INSTALLS += bin icon desktop server manpage

bin.path = $$BINDIR
isEmpty(DESTDIR) {
Expand All @@ -363,9 +351,6 @@ icon.files = ../YACReaderLibrary.svg
desktop.path = $$DATADIR/applications
desktop.files = ../YACReaderLibrary.desktop

translation.path = $$DATADIR/yacreader/languages
translation.files = ../release/languages/yacreaderlibrary_*

manpage.path = $$DATADIR/man/man1
manpage.files = ../YACReaderLibrary.1
}
1 change: 1 addition & 0 deletions YACReaderLibrary/comic_vine/comic_vine_dialog.cpp
Expand Up @@ -33,6 +33,7 @@ ComicVineDialog::ComicVineDialog(QWidget *parent)
: QDialog(parent)
{
setWindowFlags(Qt::Window);
setModal(true);

doLayout();
doStackedWidgets();
Expand Down
2 changes: 1 addition & 1 deletion YACReaderLibrary/import_widget.cpp
Expand Up @@ -11,7 +11,7 @@
#include <QGraphicsItemAnimation>
#include <QTimeLine>
// TODO: is QGLWidget needed here???
//#include <QGLWidget>
// #include <QGLWidget>
#include <QTimer>
#include <QElapsedTimer>
#include <QToolButton>
Expand Down
27 changes: 8 additions & 19 deletions YACReaderLibrary/initial_comic_info_extractor.cpp
Expand Up @@ -27,38 +27,31 @@ void InitialComicInfoExtractor::extract()
#ifndef NO_PDF
if (fi.suffix().compare("pdf", Qt::CaseInsensitive) == 0) {
#if defined Q_OS_MAC && defined USE_PDFKIT
MacOSXPDFComic *pdfComic = new MacOSXPDFComic();
auto pdfComic = std::make_unique<MacOSXPDFComic>();
if (!pdfComic->openComic(_fileSource)) {
delete pdfComic;
// QImage p;
// p.load(":/images/notCover.png");
// p.save(_target);
return;
}
#elif defined USE_PDFIUM
auto pdfComic = new PdfiumComic();
auto pdfComic = std::make_unique<PdfiumComic>();
if (!pdfComic->openComic(_fileSource)) {
delete pdfComic;
return;
}
#else
Poppler::Document *pdfComic = Poppler::Document::load(_fileSource);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
auto pdfComic = Poppler::Document::load(_fileSource);
#else
auto _pdfComic = Poppler::Document::load(_fileSource);
auto pdfComic = std::unique_ptr<Poppler::Document>(_pdfComic);
#endif
#endif

if (!pdfComic) {
QLOG_WARN() << "Extracting cover: unable to open PDF file " << _fileSource;
// delete pdfComic; //TODO check if the delete is needed
pdfComic = 0;
// QImage p;
// p.load(":/images/notCover.png");
// p.save(_target);
return;
}
#if !defined USE_PDFKIT && !defined USE_PDFIUM
// poppler only, not mac
if (pdfComic->isLocked()) {
QLOG_WARN() << "Extracting cover: unable to open PDF file " << _fileSource;
delete pdfComic;
return;
}
#endif
Expand All @@ -75,11 +68,7 @@ void InitialComicInfoExtractor::extract()
saveCover(_target, p);
} else if (_target != "") {
QLOG_WARN() << "Extracting cover: requested cover index greater than numPages " << _fileSource;
// QImage p;
// p.load(":/images/notCover.png");
// p.save(_target);
}
delete pdfComic;
}
return;
}
Expand Down
25 changes: 24 additions & 1 deletion YACReaderLibrary/library_window.cpp
Expand Up @@ -59,7 +59,7 @@

#include "comic_vine_dialog.h"
#include "api_key_dialog.h"
//#include "yacreader_social_dialog.h"
// #include "yacreader_social_dialog.h"

#include "comics_view.h"

Expand Down Expand Up @@ -139,6 +139,29 @@ void LibraryWindow::afterLaunchTasks()
}
}

bool LibraryWindow::eventFilter(QObject *object, QEvent *event)
{
if (this->isActiveWindow()) {
if (event->type() == QEvent::MouseButtonRelease) {
auto mouseEvent = static_cast<QMouseEvent *>(event);

if (mouseEvent->button() == Qt::ForwardButton) {
forwardAction->trigger();
event->accept();
return true;
}

if (mouseEvent->button() == Qt::BackButton) {
backAction->trigger();
event->accept();
return true;
}
}
}

return QMainWindow::eventFilter(object, event);
}

void LibraryWindow::createSettings()
{
settings = new QSettings(YACReader::getSettingsPath() + "/YACReaderLibrary.ini", QSettings::IniFormat); // TODO unificar la creación del fichero de config con el servidor
Expand Down
2 changes: 2 additions & 0 deletions YACReaderLibrary/library_window.h
Expand Up @@ -434,6 +434,8 @@ public slots:

void afterLaunchTasks();

bool eventFilter(QObject *object, QEvent *event) override;

private:
//! @brief Exits search mode if it is active.
//! @return true If the search mode was active when this function was called.
Expand Down
7 changes: 7 additions & 0 deletions YACReaderLibrary/main.cpp
Expand Up @@ -11,6 +11,7 @@
#include <QLibrary>
#endif
#include <QCommandLineParser>
#include <QImageReader>

#include "yacreader_global.h"
#include "yacreader_http_server.h"
Expand Down Expand Up @@ -130,6 +131,10 @@ int main(int argc, char **argv)
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QImageReader::setAllocationLimit(0);
#endif

QApplication app(argc, argv);

#ifdef FORCE_ANGLE
Expand Down Expand Up @@ -269,6 +274,8 @@ int main(int argc, char **argv)
}
#endif

app.installEventFilter(mw);

int ret = app.exec();

QLOG_INFO() << "YACReaderLibrary closed with exit code :" << ret;
Expand Down

0 comments on commit fa3e5ea

Please sign in to comment.