Skip to content

TypedArray error (does not inherit from 'GDScript') on first project load related to early update_event_cache call #2586

Open
@Atthepinao

Description

@Atthepinao

The problem

Describe the bug
I've encountered a specific error message that appears only during the very first time a project with the Dialogic addon is opened in the Godot editor (v4.4.1.stable.steam).
The error message is:

ERROR: Attempted to push_back an object into a TypedArray, that does not inherit from 'GDScript'.
   at: validate_object (core/variant/container_type_validate.h:146)
ERROR: Condition "!_p->typed.validate(value, "push_back")" is true.
   at: push_back (core/variant/array.cpp:283)

The error does not appear on subsequent loads or after using "Project -> Reload Current Project".

To Reproduce
1.Create or open a Godot 4.4.1 project with the Dialogic addon installed.
2.Ensure the Godot editor is fully closed.
3.Open the project directly via the project manager or command line.
4.Observe the editor's Output panel immediately upon loading. The TypedArray error should appear.

Screenshots

Image

System (please complete the following information):

  • OS:Windows 11
  • Godot Version: v4.4.1.stable.steam[49a5bc7b6]
  • Dialogic Version: 2.0 - Alpha 16

Solutions

The error seems to stem from a timing issue during Godot editor startup. DialogicGameHandler._ready() calls DialogicResourceUtil.update_event_cache() too early, before the engine has fully processed or registered the type information for the @tool event scripts being loaded. This leads to a failed type validation when appending these instances to the TypedArray[DialogicEvent], which implicitly expects GDScript descendants.

Workaround
Modifying DialogicGameHandler.gd's _ready() function to delay the call using call_deferred reliably prevents the error message from appearing:

func _ready() -> void:
    _collect_subsystems()
    clear()
    # DialogicResourceUtil.update_event_cache() # Original direct call
    call_deferred("_deferred_update_event_cache") # Deferred call
    dialog_ending_timeline = DialogicTimeline.new()
    dialog_ending_timeline.from_text("[clear]")

func _deferred_update_event_cache():
    DialogicResourceUtil.update_event_cache()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug 🐞Something isn't workingNeeds testingMore feedback/testing would be good

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions