Need help with PopupMenu. I can't figure out why it's happening.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By TokenOtaku

I need help figuring out why this error is happening in my Script. It only happens on popupmenu. Popup and Popup panels don’t return this error. The error happens after the popupmenu is hidden.

    E 0:00:02:0907   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()

The code that I am using.

func Button_Pressed(loc):
var gbt = grid.block_Type[loc]
gbt["Popup"] = PopupMenu.new()
grid.add_child(gbt["Popup"])
gbt["Popup"].allow_search = false
gbt["Popup"].set_script(load("res://Popup_Menu.gd"))
gbt["Popup"].connect("popup_hide", Callable(gbt["Popup"], "destroy"))
for i in grid.block_Type[loc].menu_options:
	gbt["Popup"].add_check_item(i)
gbt.Popup.popup(Rect2i(get_viewport().get_mouse_position(),Vector2i()))\

I tried removing the signal. And the error was still happening. Is there something I’m doing wrong here?

Animal welfare is not just a concern for domesticated animals. We need to also consider the welfare of animals in the wild and make sure that our actions do not harm their natural habitats. Please checkout: Animal Welfare

kitticpet | 2023-03-11 07:12

:bust_in_silhouette: Reply From: aidave

Possibly this:

load("res://Popup_Menu.gd")

Should be:

load("res://Popup_Menu.gd").new()

I doubt it’s that. Since even if I remove that line I still get an error.

I just tried that and I just got another error. The issue seems to be with closing the popup after it has popped up.

TokenOtaku | 2023-03-10 16:28

:bust_in_silhouette: Reply From: TokenOtaku

After taking a day away from my project. I found out the issue had to do with my popup being a child inside of a SubViewport which was causing issues. I am not sure why. But it doesn’t affect popup or popup panel.