Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor: Fix EditorHelpBitTooltip + ProgressDialog causes crash #91716

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion editor/editor_help.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3760,6 +3760,14 @@ EditorHelpBit::EditorHelpBit(const String &p_symbol) {

/// EditorHelpBitTooltip ///

void EditorHelpBitTooltip::_safe_queue_free() {
if (_pushing_input > 0) {
_need_free = true;
} else {
queue_free();
}
}

void EditorHelpBitTooltip::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_WM_MOUSE_ENTER:
Expand All @@ -3778,7 +3786,13 @@ void EditorHelpBitTooltip::_input_from_window(const Ref<InputEvent> &p_event) {
} else {
const Ref<InputEventMouse> mouse_event = p_event;
if (mouse_event.is_null()) {
// GH-91652. Prevents use-after-free since `ProgressDialog` calls `Main::iteration()`.
_pushing_input++;
get_parent_viewport()->push_input(p_event);
_pushing_input--;
if (_pushing_input <= 0 && _need_free) {
queue_free();
}
}
}
}
Expand Down Expand Up @@ -3839,7 +3853,7 @@ EditorHelpBitTooltip::EditorHelpBitTooltip(Control *p_target) {

timer = memnew(Timer);
timer->set_wait_time(0.2);
timer->connect("timeout", callable_mp(static_cast<Node *>(this), &Node::queue_free));
timer->connect("timeout", callable_mp(this, &EditorHelpBitTooltip::_safe_queue_free));
add_child(timer);

ERR_FAIL_NULL(p_target);
Expand Down
4 changes: 4 additions & 0 deletions editor/editor_help.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@ class EditorHelpBitTooltip : public PopupPanel {
GDCLASS(EditorHelpBitTooltip, PopupPanel);

Timer *timer = nullptr;
int _pushing_input = 0;
bool _need_free = false;

void _safe_queue_free();

protected:
void _notification(int p_what);
Expand Down
Loading