From 05f23de1ed7b106ee91000def9e6d12c55687604 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Mon, 23 Dec 2019 16:16:15 +0100 Subject: [PATCH] Clear the popup on scene clear Fixes #257 --- src/GUI/graphicsscene.cpp | 6 ++++++ src/GUI/graphicsscene.h | 3 +++ src/GUI/popup.cpp | 6 ++++++ src/GUI/popup.h | 1 + 4 files changed, 16 insertions(+) diff --git a/src/GUI/graphicsscene.cpp b/src/GUI/graphicsscene.cpp index fa2fa7ad..a51a5754 100644 --- a/src/GUI/graphicsscene.cpp +++ b/src/GUI/graphicsscene.cpp @@ -46,3 +46,9 @@ void GraphicsScene::helpEvent(QGraphicsSceneHelpEvent *event) /* No need to process QGraphicsScene::helpEvent() */ } + +void GraphicsScene::clear() +{ + Popup::clear(); + QGraphicsScene::clear(); +} diff --git a/src/GUI/graphicsscene.h b/src/GUI/graphicsscene.h index 070aa642..e558f0bc 100644 --- a/src/GUI/graphicsscene.h +++ b/src/GUI/graphicsscene.h @@ -18,6 +18,9 @@ class GraphicsScene : public QGraphicsScene public: GraphicsScene(QObject *parent = 0) : QGraphicsScene(parent) {} +public slots: + void clear(); + protected: void helpEvent(QGraphicsSceneHelpEvent *event); diff --git a/src/GUI/popup.cpp b/src/GUI/popup.cpp index 0aaec874..5d500fa6 100644 --- a/src/GUI/popup.cpp +++ b/src/GUI/popup.cpp @@ -163,3 +163,9 @@ void Popup::show(const QPoint &pos, const QString &text, QWidget *w) PopupLabel::_instance->place(pos, w); PopupLabel::_instance->showNormal(); } + +void Popup::clear() +{ + if (PopupLabel::_instance) + PopupLabel::_instance->deleteLater(); +} diff --git a/src/GUI/popup.h b/src/GUI/popup.h index 22d51317..1d132ebe 100644 --- a/src/GUI/popup.h +++ b/src/GUI/popup.h @@ -9,6 +9,7 @@ class Popup { public: static void show(const QPoint &pos, const QString &text, QWidget *w); + static void clear(); }; #endif // POPUP_H