From 9ae6357c349d7d459b442b238d0cbb94a18a0934 Mon Sep 17 00:00:00 2001 From: BruebachL <44814898+BruebachL@users.noreply.github.com> Date: Sun, 4 May 2025 02:03:53 +0200 Subject: [PATCH] Properly manage hover-zoom child widget in CardInfoPictureWidget destructor. (#5900) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Lukas BrĂ¼bach --- .../ui/widgets/cards/card_info_picture_widget.cpp | 12 ++++++++++++ .../ui/widgets/cards/card_info_picture_widget.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/cockatrice/src/client/ui/widgets/cards/card_info_picture_widget.cpp b/cockatrice/src/client/ui/widgets/cards/card_info_picture_widget.cpp index 4ee3de5eb..5e275f8e9 100644 --- a/cockatrice/src/client/ui/widgets/cards/card_info_picture_widget.cpp +++ b/cockatrice/src/client/ui/widgets/cards/card_info_picture_widget.cpp @@ -64,6 +64,12 @@ CardInfoPictureWidget::CardInfoPictureWidget(QWidget *parent, const bool _hoverT }); } +CardInfoPictureWidget::~CardInfoPictureWidget() +{ + enlargedPixmapWidget->hide(); + enlargedPixmapWidget->deleteLater(); +} + /** * @brief Sets the card to be displayed and updates the pixmap. * @param card A shared pointer to the card information (CardInfoPtr). @@ -341,6 +347,12 @@ void CardInfoPictureWidget::mousePressEvent(QMouseEvent *event) emit cardClicked(); } +void CardInfoPictureWidget::hideEvent(QHideEvent *event) +{ + enlargedPixmapWidget->hide(); + QWidget::hideEvent(event); +} + QMenu *CardInfoPictureWidget::createRightClickMenu() { auto *cardMenu = new QMenu(this); diff --git a/cockatrice/src/client/ui/widgets/cards/card_info_picture_widget.h b/cockatrice/src/client/ui/widgets/cards/card_info_picture_widget.h index 10cc422aa..79de74526 100644 --- a/cockatrice/src/client/ui/widgets/cards/card_info_picture_widget.h +++ b/cockatrice/src/client/ui/widgets/cards/card_info_picture_widget.h @@ -21,6 +21,7 @@ public: explicit CardInfoPictureWidget(QWidget *parent = nullptr, bool hoverToZoomEnabled = false, bool raiseOnEnter = false); + ~CardInfoPictureWidget(); CardInfoPtr getInfo() { return info; @@ -52,6 +53,7 @@ protected: void moveEvent(QMoveEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; void mousePressEvent(QMouseEvent *event) override; + void hideEvent(QHideEvent *event) override; void loadPixmap(); [[nodiscard]] const QPixmap &getResizedPixmap() const {