summaryrefslogtreecommitdiff
path: root/scene/main
diff options
context:
space:
mode:
authorRindbee <idleman@yeah.net>2022-10-04 10:12:11 +0800
committerRindbee <idleman@yeah.net>2022-10-04 11:58:02 +0800
commit9a05ea231a41ebb6c53540532b1094057cd9487e (patch)
tree48358130f6737e54abe051590cbae5b21931af22 /scene/main
parent4b52c6caef8a9e5d940ce0977d5c467296ac5805 (diff)
Make sure to reset the tooltip of its gui_parent when the viewport is removed
Diffstat (limited to 'scene/main')
-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;