Skip to content

WorldScape3D: Fix crash with empty data directory outside the editor - #1532

Merged
OldDev78 merged 1 commit into
Redot-Engine:masterfrom
KazW:fix-worldscape-empty-data-dir
Oct 19, 2026
Merged

OldDev78 merged 1 commit into
Redot-Engine:masterfrom
KazW:fix-worldscape-empty-data-dir

Conversation

@KazW

@KazW KazW commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1531.

Problem

When a scene has a WorldScape3D node with an empty data_directory, running the game with the editor binary crashes with signal 11. This includes pressing Play in the editor. WorldScape3DData::initialize() calls select_data_directory() in every TOOLS_ENABLED build, and that does EditorNode::get_singleton()->add_child(...). A game run with the editor binary has no EditorNode, so the singleton is null.

Fix

  • The folder dialog now only opens when Engine::is_editor_hint() is true (IS_EDITOR). Editor behaviour doesn't change.
  • Anywhere else (a game run with the editor binary, or an export template), it logs WorldScape3D data directory not set. Terrain will not be loaded and 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's LOG macro is compiled out without DEBUG_ENABLED.

Testing

On Linux (CachyOS), with a dev_build=yes editor built from this branch on master (96e43d3). I used the MRP from the issue, with a WorldScape3D node and an empty data_directory.

Run master This PR
Run the game, --headless --quit-after 60 signal 11 (2 out of 2 runs) exit 0, error printed (3 out of 3 runs)
Headless editor, -e --quit-after 120 exit 0 exit 0
Same scene with data_directory set to an empty folder exit 0 exit 0

I 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 master and 26.3-stable when data_directory points 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

@KazW
KazW requested review from a team October 18, 2026 16:05
@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: Redot-Engine/redot-engine/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2afbe4ae-48d9-42d3-8efc-a2b49cf4a2a2
📥 Commits

Reviewing files that changed from the base of the PR and between 132958a and e24f032.

📒 Files selected for processing: 1
  • modules/worldscape_3d/worldscape_3d_data.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

Walkthrough

When the data directory is empty, WorldScape3DData::initialize opens the directory selector only in the editor. In other contexts, it logs that terrain will not load.

Changes

WorldScape3D directory handling

Layer / File(s) Summary
Empty-directory initialization
modules/worldscape_3d/worldscape_3d_data.cpp
When the data directory is empty, the selector opens only when IS_EDITOR is true. Otherwise, initialization logs that terrain will not load.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: olddev78, arctis-fireblight

Merge Risk: ⚪ Minimal · up to e24f0

The empty-directory case reports the problem without attempting terrain loading. No actionable merge risk is established.

Pre-merge checks: Passed 5
Check name Status Explanation
Linked Issues check Passed The PR satisfies the coding requirements in #1531. For an empty data_directory, WorldScape3DData::initialize opens the directory picker only in editor mode. Other contexts log the required error a…
Out of Scope Changes check Passed The reported change is limited to empty-directory handling in modules/worldscape_3d/worldscape_3d_data.cpp. The editor-mode guard and non-editor error path directly implement #1531. No unrelated pro…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: preventing a crash when the WorldScape3D data directory is empty outside the editor.
Full details: Linked Issues check

Explanation

The PR satisfies the coding requirements in #1531. For an empty data_directory, WorldScape3DData::initialize opens the directory picker only in editor mode. Other contexts log the required error and continue without loading terrain data. The existing load path remains for configured directories. The reported headless and Play tests cover the requested execution modes.

Full details: Out of Scope Changes check

Explanation

The reported change is limited to empty-directory handling in modules/worldscape_3d/worldscape_3d_data.cpp. The editor-mode guard and non-editor error path directly implement #1531. No unrelated production changes are identified.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@KazW

KazW commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

@OldDev78 since this is WorldScape3D related, can you take a look, please?

@OldDev78 OldDev78 self-assigned this Oct 18, 2026

@OldDev78 OldDev78 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice, small patch. 👍
This bug was introduced when trying to automate the data directory selection, good catch.
We just need to simplify the error message.

Comment thread modules/worldscape_3d/worldscape_3d_data.cpp Outdated
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
@KazW
KazW force-pushed the fix-worldscape-empty-data-dir branch from 132958a to e24f032 Compare October 18, 2026 16:54
@OldDev78
OldDev78 self-requested a review October 18, 2026 16:55

@OldDev78 OldDev78 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@DaveTheEggman DaveTheEggman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@OldDev78
OldDev78 merged commit 1e131cd into Redot-Engine:master Oct 19, 2026
19 checks passed
@github-project-automation github-project-automation Bot moved this from Open to Done in Engine Overview Oct 19, 2026
@KazW
KazW deleted the fix-worldscape-empty-data-dir branch October 19, 2026 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Game crashes on start when a WorldScape3D's data_directory is empty (editor binary)

3 participants