Repository navigation
WorldScape3D: Fix crash with empty data directory outside the editor - #1532
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughWhen the data directory is empty, ChangesWorldScape3D directory handling
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to
|
|
@OldDev78 since this is WorldScape3D related, can you take a look, please? |
WorldScape3DData::initialize() opened the data directory dialog whenever data_directory was empty in a TOOLS_ENABLED build. When a game is run from the editor (Play), the editor binary runs without an EditorNode, so EditorNode::get_singleton() is null and add_child() segfaulted. Only show the dialog when Engine::is_editor_hint() is true. Otherwise log an error explaining that data_directory isn't set, and continue without loading terrain data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B7GMHzgkmsQbz3CYaSrxxS
132958a to
e24f032
Compare
Fixes #1531.
Problem
When a scene has a
WorldScape3Dnode with an emptydata_directory, running the game with the editor binary crashes with signal 11. This includes pressing Play in the editor.WorldScape3DData::initialize()callsselect_data_directory()in everyTOOLS_ENABLEDbuild, and that doesEditorNode::get_singleton()->add_child(...). A game run with the editor binary has noEditorNode, so the singleton is null.Fix
Engine::is_editor_hint()is true (IS_EDITOR). Editor behaviour doesn't change.WorldScape3D data directory not set. Terrain will not be loadedand continues. A game run from the editor shows this in Debugger > Errors.Export templates never had the crash, because
select_data_directory()isn't compiled into them. Before this change they silently skipped loading. Debug templates now print the same error. Release builds don't print it, because the module'sLOGmacro is compiled out withoutDEBUG_ENABLED.Testing
On Linux (CachyOS), with a
dev_build=yeseditor built from this branch onmaster(96e43d3). I used the MRP from the issue, with aWorldScape3Dnode and an emptydata_directory.master--headless --quit-after 60-e --quit-after 120data_directoryset to an empty folderI also tested it manually in the editor. Pressing Play runs the game, and the error appears in the Debugger's Errors tab.
Unrelated to this fix: with no regions loaded, a small raised square renders near the world origin on the flat background. It also happens on
masterand 26.3-stable whendata_directorypoints to an empty folder. I'll look into it separately.AI disclosure
Per
AI_POLICY.md: I used Claude Code to find the cause, write the fix, run the builds and tests, and draft this description. The change was also put through an AI review before submission. I tested the change manually before submitting.🤖 Generated with Claude Code