summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-10-04 10:32:51 +0200
committerRémi Verschelde <rverschelde@gmail.com>2022-10-04 10:32:51 +0200
commit38dd7537150b2b2fb5d63606b778d0e052f75101 (patch)
tree09d81cb49ceb80be0c1b0fc95c5aaae11a891b49
parentb58f34372c57b362d70a1a3453d903b7798865f6 (diff)
parent9a05ea231a41ebb6c53540532b1094057cd9487e (diff)
Merge pull request #66859 from Rindbee/reset-gui_parent
Make sure to reset the tooltip of its gui_parent when the viewport is removed
-rw-r--r--scene/main/viewport.cpp12
-rw-r--r--scene/main/viewport.h1
2 files changed, 9 insertions, 4 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 05b4f181c2..0795d91035 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -499,6 +499,13 @@ void Viewport::_notification(int p_what) {
// exit event if the change in focus results in the mouse exiting
// the window.
} break;
+
+ case NOTIFICATION_PREDELETE: {
+ if (gui_parent) {
+ gui_parent->gui.tooltip_popup = nullptr;
+ gui_parent->gui.tooltip_label = nullptr;
+ }
+ } break;
}
}
@@ -1155,8 +1162,6 @@ void Viewport::_gui_cancel_tooltip() {
}
if (gui.tooltip_popup) {
gui.tooltip_popup->queue_delete();
- gui.tooltip_popup = nullptr;
- gui.tooltip_label = nullptr;
}
}
@@ -1219,8 +1224,6 @@ void Viewport::_gui_show_tooltip() {
// Remove previous popup if we change something.
if (gui.tooltip_popup) {
memdelete(gui.tooltip_popup);
- gui.tooltip_popup = nullptr;
- gui.tooltip_label = nullptr;
}
if (!tooltip_owner) {
@@ -1252,6 +1255,7 @@ void Viewport::_gui_show_tooltip() {
panel->set_flag(Window::FLAG_POPUP, false);
panel->set_wrap_controls(true);
panel->add_child(base_tooltip);
+ panel->gui_parent = this;
gui.tooltip_popup = panel;
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index 471dc41246..6f67649ea3 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -208,6 +208,7 @@ private:
friend class ViewportTexture;
Viewport *parent = nullptr;
+ Viewport *gui_parent = nullptr; // Whose gui.tooltip_popup it is.
AudioListener2D *audio_listener_2d = nullptr;
Camera2D *camera_2d = nullptr;