diff --git a/YACReader/magnifying_glass.cpp b/YACReader/magnifying_glass.cpp index 28cce728..9db4b137 100644 --- a/YACReader/magnifying_glass.cpp +++ b/YACReader/magnifying_glass.cpp @@ -38,9 +38,9 @@ void MagnifyingGlass::updateImage(int x, int y) int zoomHeight = static_cast(height() * zoomLevel); auto p = (Viewer *)parent(); int currentPos = p->verticalScrollBar()->sliderPosition(); - const QPixmap *image = p->pixmap(); - int iWidth = image->width(); - int iHeight = image->height(); + const QPixmap image = p->pixmap(); + int iWidth = image.width(); + int iHeight = image.height(); float wFactor = static_cast(iWidth) / p->widget()->width(); float hFactor = static_cast(iHeight) / p->widget()->height(); zoomWidth *= wFactor; @@ -67,12 +67,12 @@ void MagnifyingGlass::updateImage(int x, int y) outImage = true; } - if (xp + zoomWidth >= image->width()) { - zw -= xp + zw - image->width(); + if (xp + zoomWidth >= image.width()) { + zw -= xp + zw - image.width(); outImage = true; } - if (yp + zoomHeight >= image->height()) { - zh -= yp + zh - image->height(); + if (yp + zoomHeight >= image.height()) { + zh -= yp + zh - image.height(); outImage = true; } if (outImage) { @@ -81,11 +81,11 @@ void MagnifyingGlass::updateImage(int x, int y) img.fill(Configuration::getConfiguration().getBackgroundColor()); if (zw > 0 && zh > 0) { QPainter painter(&img); - painter.drawPixmap(xOffset, yOffset, image->copy(xp, yp, zw, zh)); + painter.drawPixmap(xOffset, yOffset, image.copy(xp, yp, zw, zh)); } setPixmap(QPixmap().fromImage(img)); } else - setPixmap(image->copy(xp, yp, zoomWidth, zoomHeight)); + setPixmap(image.copy(xp, yp, zoomWidth, zoomHeight)); } else { int xp = static_cast(((x - p->widget()->pos().x()) * wFactor) - zoomWidth / 2); int yp = static_cast((y + currentPos) * hFactor - zoomHeight / 2); @@ -108,12 +108,12 @@ void MagnifyingGlass::updateImage(int x, int y) outImage = true; } - if (xp + zoomWidth >= image->width()) { - zw -= xp + zw - image->width(); + if (xp + zoomWidth >= image.width()) { + zw -= xp + zw - image.width(); outImage = true; } - if (yp + zoomHeight >= image->height()) { - zh -= yp + zh - image->height(); + if (yp + zoomHeight >= image.height()) { + zh -= yp + zh - image.height(); outImage = true; } if (outImage) { @@ -122,11 +122,11 @@ void MagnifyingGlass::updateImage(int x, int y) img.fill(Configuration::getConfiguration().getBackgroundColor()); if (zw > 0 && zh > 0) { QPainter painter(&img); - painter.drawPixmap(xOffset, yOffset, image->copy(xp, yp, zw, zh)); + painter.drawPixmap(xOffset, yOffset, image.copy(xp, yp, zw, zh)); } setPixmap(QPixmap().fromImage(img)); } else - setPixmap(image->copy(xp, yp, zoomWidth, zoomHeight)); + setPixmap(image.copy(xp, yp, zoomWidth, zoomHeight)); } move(static_cast(x - float(width()) / 2), static_cast(y - float(height()) / 2)); } diff --git a/YACReader/main_window_viewer.cpp b/YACReader/main_window_viewer.cpp index 8f9e496f..9bd53f53 100644 --- a/YACReader/main_window_viewer.cpp +++ b/YACReader/main_window_viewer.cpp @@ -978,9 +978,10 @@ void MainWindowViewer::saveImage() if (!pathFile.isEmpty()) { QFileInfo fi(pathFile); currentDirectoryImgDest = fi.absolutePath(); - const QPixmap *p = viewer->pixmap(); - if (p != nullptr) - p->save(pathFile); + const QPixmap p = viewer->pixmap(); + if (!p.isNull()) { + p.save(pathFile); + } } } diff --git a/YACReader/viewer.cpp b/YACReader/viewer.cpp index 2ac31308..bf7df3b9 100644 --- a/YACReader/viewer.cpp +++ b/YACReader/viewer.cpp @@ -773,9 +773,13 @@ void Viewer::mouseMoveEvent(QMouseEvent *event) } } -const QPixmap *Viewer::pixmap() +const QPixmap Viewer::pixmap() { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) return content->pixmap(); +#else + return *(content->pixmap()); +#endif } void Viewer::magnifyingGlassSwitch() diff --git a/YACReader/viewer.h b/YACReader/viewer.h index f7aab2ed..393815d9 100644 --- a/YACReader/viewer.h +++ b/YACReader/viewer.h @@ -178,7 +178,7 @@ private: public: Viewer(QWidget *parent = nullptr); ~Viewer(); - const QPixmap *pixmap(); + const QPixmap pixmap(); // Comic * getComic(){return comic;} const BookmarksDialog *getBookmarksDialog() { return bd; } // returns the current index starting in 1 [1,nPages]