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

ScriptCreateDialog generates errors when new script language is added #104812

Open
Naros opened this issue Mar 30, 2025 · 1 comment · May be fixed by #104868
Open

ScriptCreateDialog generates errors when new script language is added #104812

Naros opened this issue Mar 30, 2025 · 1 comment · May be fixed by #104868

Comments

@Naros
Copy link
Contributor

Naros commented Mar 30, 2025

Tested versions

4.4.1.stable

System information

Fedora 41

Issue description

When a GDExtension or plug-in adds a new ScriptExtension and ScriptLanguageExtension, Godot 4.4 reports the following immediately after starting up when the .godot directory does not yet exist.

Godot Engine v4.4.stable.custom_build (c) 2007-present Juan Linietsky, Ariel Manzur & Godot Contributors.
--- Debug adapter server started on port 6006 ---
--- GDScript language server started on port 6005 ---
  ERROR: scene/gui/popup_menu.cpp:1776 - Index p_idx = 1 is out of bounds (items.size() = 1).
  ERROR: scene/gui/popup_menu.cpp:1776 - Index p_idx = 1 is out of bounds (items.size() = 1).
  ERROR: scene/gui/popup_menu.cpp:1776 - Index p_idx = 1 is out of bounds (items.size() = 1).
  ERROR: scene/gui/popup_menu.cpp:1776 - Index p_idx = 1 is out of bounds (items.size() = 1).
  ERROR: scene/gui/popup_menu.cpp:1776 - Index p_idx = 1 is out of bounds (items.size() = 1).
  ERROR: scene/gui/popup_menu.cpp:1776 - Index p_idx = 1 is out of bounds (items.size() = 1).

After careful review, the errors are directly from ScriptCreateDialog due to how the language_menu list is managed. The list is created inside the constructor and when the NOTIFICATION_THEME_CHANGED is called the first time, the ScriptServer only reports there is 1 language count, so everything is happy. But when the next NOTIFICATION_THEME_CHANGED is called, the ScriptServer reports there are now 2 languages present; however the language_menu only has a single item in the list, which leads to these errors.

Steps to reproduce

  1. Have a project that has a GDExtension that supplies a ScriptLanguageExtension and ScriptLanguage.
  2. Make sure the project has no .godot directory in the root of the project.
  3. Load the project in the Godot 4.4 editor, errors are shown in the output panel.

I should note that the language is being registered inside the MODULE_INITIALIZATION_LEVEL_SERVERS module handler, but I've tried in the SCENE level as well, both yield the same result.

I have not tried using implementations from GDScript, this was specifically from GDExtension.

Minimal reproduction project (MRP)

N/A

@dsnopek
Copy link
Contributor

dsnopek commented Mar 31, 2025

I haven't looked at this too closely, but it does seem like a bug in ScriptCreateDialog.

The number of scripting languages can change at any time, given that GDExtensions may not be loaded at editor startup, and can be loaded later (like if the developer adds a new extension from the asset library), so it should account for that happening

@Naros Naros linked a pull request Apr 1, 2025 that will close this issue
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.

2 participants