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

Errors when opening dialog from manually sent close notification #100753

Open
rhofour opened this issue Dec 22, 2024 · 0 comments
Open

Errors when opening dialog from manually sent close notification #100753

rhofour opened this issue Dec 22, 2024 · 0 comments

Comments

@rhofour
Copy link
Contributor

rhofour commented Dec 22, 2024

Tested versions

Reproducible in (at least): 4.3, 4.4dev2, and 4.4dev7

I get the same behavior with both C# and GDscript

System information

Linux (Fedora 41 using Gnome)

Issue description

Motivation: When the user closes my application I would like to open a dialog prompting them to save if content was modified.

Issue:
When I listen for NOTIFICATION_WM_CLOSE_REQUEST and show a dialog this works as expected. However, if I manually trigger the same notification from a button or menu (using get_tree().root.propagate_notification) instead I get the following error:

E 0:00:01:0786   popup_repro.gd:11 @ _notification(): Parent node is busy setting up children, `add_child()` failed. Consider using `add_child.call_deferred(child)` instead.
  <C++ Error>    Condition "data.blocked > 0" is true.
  <C++ Source>   scene/main/node.cpp:1572 @ add_child()
  <Stack Trace>  popup_repro.gd:11 @ _notification()
                 popup_repro.gd:5 @ <anonymous lambda>()

This is similar to #34157 except I don't see the error when the close notification is sent from the window manager.

If I replace cd.popup_exclusive_centered(self) with cd.popup_exclusive_centered.call_deferred(self) this works as expected, but it's not clear why this should be necessary.

Steps to reproduce

  1. Open repro project
  2. Click the button
  3. Observe error

Minimal reproduction project (MRP)

popup-repro.zip

Attached is a tiny repro project, the only code of which is repeated here:

extends Control

func _ready() -> void:
	get_tree().set_auto_accept_quit(false)
	$Button.pressed.connect(func(): get_tree().root.propagate_notification(NOTIFICATION_WM_CLOSE_REQUEST))

func _notification(what: int) -> void:
	if (what == NOTIFICATION_WM_CLOSE_REQUEST):
		var cd = ConfirmationDialog.new()
		cd.get_ok_button().pressed.connect(func(): get_tree().quit())
		cd.popup_exclusive_centered(self)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants