Add error checks for DirAccess creation.

This commit is contained in:
Saracen 2023-09-26 03:07:43 +01:00
parent 43b9e89a07
commit 3f4513d4de
10 changed files with 26 additions and 0 deletions

View file

@ -2224,6 +2224,8 @@ Error Main::setup2() {
// Editor setting class is not available, load config directly.
if (!init_use_custom_screen && (editor || project_manager) && EditorPaths::get_singleton()->are_paths_valid()) {
Ref<DirAccess> dir = DirAccess::open(EditorPaths::get_singleton()->get_config_dir());
ERR_FAIL_COND_V(dir.is_null(), FAILED);
String config_file_name = "editor_settings-" + itos(VERSION_MAJOR) + ".tres";
String config_file_path = EditorPaths::get_singleton()->get_config_dir().path_join(config_file_name);
if (dir->file_exists(config_file_name)) {
@ -3295,6 +3297,8 @@ bool Main::start() {
if (sep == -1) {
Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
ERR_FAIL_COND_V(da.is_null(), false);
local_game_path = da->get_current_dir().path_join(local_game_path);
} else {
Ref<DirAccess> da = DirAccess::open(local_game_path.substr(0, sep));