From 6177d4a2c41bcd1fd576a2937cc00cbd17f685cb Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Thu, 20 Jun 2024 15:59:34 +0200 Subject: [PATCH] ContextAlbum: Use const reference for image parameter --- src/context/contextalbum.cpp | 14 ++++++++------ src/context/contextalbum.h | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/context/contextalbum.cpp b/src/context/contextalbum.cpp index 2107b2ce9..f28975dbd 100644 --- a/src/context/contextalbum.cpp +++ b/src/context/contextalbum.cpp @@ -141,11 +141,7 @@ void ContextAlbum::UpdateWidth(const int new_width) { } -void ContextAlbum::SetImage(QImage image) { - - if (image.isNull()) { - image = image_strawberry_; - } +void ContextAlbum::SetImage(const QImage &image) { if (downloading_covers_) { downloading_covers_ = false; @@ -156,7 +152,13 @@ void ContextAlbum::SetImage(QImage image) { QPixmap pixmap_previous = pixmap_current_; qreal opacity_previous = pixmap_current_opacity_; - image_original_ = image; + if (image.isNull()) { + image_original_ = image_strawberry_; + } + else { + image_original_ = image; + } + pixmap_current_opacity_ = 0.0; ScaleCover(); diff --git a/src/context/contextalbum.h b/src/context/contextalbum.h index 4af2d2115..4944f57d2 100644 --- a/src/context/contextalbum.h +++ b/src/context/contextalbum.h @@ -51,7 +51,7 @@ class ContextAlbum : public QWidget { explicit ContextAlbum(QWidget *parent = nullptr); void Init(ContextView *context_view, AlbumCoverChoiceController *album_cover_choice_controller); - void SetImage(QImage image = QImage()); + void SetImage(const QImage &image = QImage()); void UpdateWidth(const int width); protected: