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

PopupMenu sub-menus error on selection - window_get_popup_safe_rect: Condition "!windows.has(p_window)" is true #76480

Open
devvoid opened this issue Apr 26, 2023 · 3 comments · May be fixed by #76500

Comments

@devvoid
Copy link

devvoid commented Apr 26, 2023

Godot version

4.0.2

System information

Windows 10

Issue description

Creating a sub-menu of a PopupMenu and then selecting one of its options prints an error message to the console. Signals are fired correctly and the menu displays correctly, nothing seems to be wrong beyond just the error message:

E 0:00:06:0394   window_get_popup_safe_rect: Condition "!windows.has(p_window)" is true. Returning: Rect2i()
  <C++ Source>   platform/windows/display_server_windows.cpp:2361 @ window_get_popup_safe_rect()

Steps to reproduce

  1. Create a MenuButton
  2. Add a sub-menu via code
  3. Click an option in that sub-menu

Minimal reproduction project

SubMenuProblem.zip

@winston-yallow
Copy link
Contributor

It seems to me like the popup menu receives focus immediately after the window is already deleted. Therefore it can't be found anymore.

@tctimmeh
Copy link

I'm getting the same error with a non-exclusive popup ConfirmationDialog that has an OptionButton inside. When I click the option button I get

E 0:00:03:0545   window_get_popup_safe_rect: Condition "!windows.has(p_window)" is true. Returning: Rect2i()
  <C++ Source>   platform/linuxbsd/x11/display_server_x11.cpp:3842 @ window_get_popup_safe_rect()

then the dialog window emits a cancelled signal and the window closes without even showing the button options, thus making the dialog window unusable.

Turning on the window's exclusive flag prevents the problem.

Godot 4.1 on Ubuntu 23.04

@Sauermann
Copy link
Contributor

Sauermann commented Jul 12, 2023

With the recently merged #78476, the error output has changed into:

E 0:00:04:0268   subwindow_get_popup_safe_rect: Condition "index == -1" is true. Returning: Rect2i()
  <C++ Source>   scene/main/viewport.cpp:3535 @ subwindow_get_popup_safe_rect()

At the time, PopupMenu::_parent_focused gets executed, Rect2 safe_area = get_embedder()->subwindow_get_popup_safe_rect(this); fails, because that popup was already closed previously.

Currently the following doesn't work in the case of embedded windows:

  1. Click on a menu-item that opens a submenu
  2. Click again on the same menu-item that opens a submenu

Current behavior: The submenu closes and opens
Expected behavior: The submenu should stay open

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants