Skip to content

Commit

Permalink
Fixed crash with a custom MainLoop or with --check-only
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriySalnikov committed Nov 13, 2024
1 parent 4006fc2 commit 742443c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/debug_draw_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ void DebugDrawManager::_unregister_singleton_aliases(const TypedArray<StringName
void DebugDrawManager::_integrate_into_engine() {
ZoneScoped;

if (!SCENE_TREE()) {
// Running via the console with a custom `MainLoop` or with `--check-only`
set_debug_enabled(false);
return;
}

// disable by default for headless
{
if (Engine::get_singleton()->has_singleton("DisplayServer")) {
Expand Down
2 changes: 1 addition & 1 deletion src/register_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void uninitialize_debug_draw_3d_module(ModuleInitializationLevel p_level) {
// If this library is disabled manually before deleting the scene tree (hot-reload),
// then an attempt is made to delete this node manually.
DebugDrawManager *debug_draw_manager = Object::cast_to<DebugDrawManager>(ObjectDB::get_instance(debug_draw_manager_id));
if (Engine::get_singleton()->get_main_loop() && debug_draw_manager) {
if (debug_draw_manager) {
memdelete(debug_draw_manager);
}
debug_draw_manager_id = 0;
Expand Down

0 comments on commit 742443c

Please sign in to comment.