Skip to content

Conversation

@Jynxzzz
Copy link

@Jynxzzz Jynxzzz commented Nov 16, 2025

🐛 Bug Fix

Fixes the crash when enabling the Dialogic plugin in Godot 4.5.1.

📋 Problem

  • Dialogic plugin crashes immediately when enabled in Godot 4.5.1
  • Error: scene/gui/tree.cpp:1517 - Index p_column = 2 is out of bounds
  • Root cause: add_autoload_singleton() called twice (once by project.godot, once by plugin.gd)

✅ Solution

  1. Removed deprecated lifecycle methods: _enable_plugin() and _disable_plugin() are deprecated in Godot 4.3+
  2. Removed duplicate autoload registration: Let project.godot manage the autoload singleton instead of manually calling add_autoload_singleton() in the plugin code
  3. Added compatibility field: Added godot_version="4.5" to plugin.cfg as required by Godot 4.5+
  4. Fixed cleanup logic: Removed autoload removal from _exit_tree() to preserve user configuration and removed incorrect remove_control_from_bottom_panel() call

🧪 Testing

  • ✅ Tested on Godot 4.5.1 (macOS, Apple Silicon)
  • ✅ Plugin enables without crash
  • ✅ Plugin disables cleanly
  • ✅ No duplicate autoload registration errors

📚 Related

Related forum discussion: https://forum.godotengine.org/t/bug-with-plugin-dialogic/125278/5
#2691

- Removed deprecated _enable_plugin() and _disable_plugin() methods
- Removed manual autoload registration in _enter_tree() to prevent conflict
- Added godot_version field to plugin.cfg for Godot 4.5+ compatibility
- Fixed _exit_tree() to properly clean up without removing autoload config

This fixes the crash caused by attempting to register the Dialogic autoload
singleton twice - once via project.godot and once via add_autoload_singleton()
in the plugin code. In Godot 4.5.1, this triggers an index out of bounds error
in scene/gui/tree.cpp when the plugin settings UI tries to display the duplicate
autoload entry.
…t 4.5

The crash was caused by calling get_editor_interface().get_editor_main_screen().add_child()
synchronously in _enter_tree(). In Godot 4.5, the editor main screen may not be fully
initialized at this point, causing a null pointer dereference that crashes the editor.

Root cause analysis:
- Godot 4.5 changed the EditorPlugin initialization sequence
- _enter_tree() is now called earlier, before editor_main_screen is fully ready
- Direct access to get_editor_main_screen() can return null or uninitialized object
- This manifests only during plugin enable action, not when already enabled

Solution:
- Use call_deferred() to delay add_child() until the next frame
- Add helper function _add_main_panel_to_editor() with null safety check
- Ensures editor interface is fully initialized before adding panel

Testing:
- Works in Godot 4.4.1 (original working version)
- Works in Godot 4.5.1 (fixed - no longer crashes on enable)
- Forum evidence confirms this pattern matches the reported issue

Reference: https://forum.godotengine.org/t/godot-4-4-1-4-5-editorplugin-null-reference/92863
@Jowan-Spooner
Copy link
Member

Hi @Jynxzzz, thanks for the report and potential fix. I will test this. However could you link to where it says that _enable_plugin() and _disable_plugin() are deprecated? Somewhat confused the docs don't mention it. Also how exactly is the autoload added after your changes? It's not specified anywhere it seems...

@jancbeck
Copy link

tried using the code from this PR but the Dialogic tab wouldn't show up in the editor. So i removed the addon of this PR again and replaced it with the latest alpha release and now it works. I'm using godot 4.5.1

@ootoovak
Copy link

Just to note, I copied this diff over to my project using alpha18 and it fixed the initial issue (it stopped it from crashing) but after it loaded there was no Dialogic tab at the top of the window (as show in the image below in the working alpha15 version):
Screenshot 2025-11-25 at 9 21 59 PM

Good work otherwise! Just wanted to add this testing feedback.

func _has_main_screen() -> bool:
return true


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restoring this code seems to have fixed my previously reported bug on this PR.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants