Skip to content

Commit 318a817

Browse files
committed
Merge pull request #107498 from bruvzg/force_native_crash
Fix `set_force_native` when window is not in tree.
2 parents 3a20049 + 5ea0baa commit 318a817

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

scene/main/window.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1370,7 +1370,7 @@ void Window::set_force_native(bool p_force_native) {
13701370
return;
13711371
}
13721372
force_native = p_force_native;
1373-
if (!is_in_edited_scene_root() && get_tree()->get_root()->is_embedding_subwindows()) {
1373+
if (!is_in_edited_scene_root() && is_inside_tree() && get_tree()->get_root()->is_embedding_subwindows()) {
13741374
set_embedding_subwindows(force_native);
13751375
}
13761376
}
@@ -1502,6 +1502,9 @@ void Window::_notification(int p_what) {
15021502
if (!ProjectSettings::get_singleton()->is_connected("settings_changed", callable_mp(this, &Window::_settings_changed))) {
15031503
ProjectSettings::get_singleton()->connect("settings_changed", callable_mp(this, &Window::_settings_changed));
15041504
}
1505+
} else if (get_parent() && get_tree()->get_root()->is_embedding_subwindows()) {
1506+
// Is not the main window and main window is embedding.
1507+
set_embedding_subwindows(force_native);
15051508
}
15061509

15071510
bool embedded = false;

0 commit comments

Comments
 (0)