diff options
author | kobewi <kobewi4e@gmail.com> | 2024-04-18 13:03:21 +0200 |
---|---|---|
committer | kobewi <kobewi4e@gmail.com> | 2024-04-18 13:03:21 +0200 |
commit | a00527e4153cf6e2fe22150f3c869c318b66e895 (patch) | |
tree | 9cdbfd1bad407b35a701e3b6efa14b8e00da77cf /editor/project_manager | |
parent | 2543d192c3f74640393f245e48fdf70e241dbe37 (diff) | |
download | redot-engine-a00527e4153cf6e2fe22150f3c869c318b66e895.tar.gz |
Fix folder scan replacing project list
Diffstat (limited to 'editor/project_manager')
-rw-r--r-- | editor/project_manager/project_list.cpp | 42 | ||||
-rw-r--r-- | editor/project_manager/project_list.h | 1 |
2 files changed, 27 insertions, 16 deletions
diff --git a/editor/project_manager/project_list.cpp b/editor/project_manager/project_list.cpp index aa93d9414b..d125754dd7 100644 --- a/editor/project_manager/project_list.cpp +++ b/editor/project_manager/project_list.cpp @@ -469,23 +469,19 @@ void ProjectList::update_project_list() { // If you have 150 projects, it may read through 150 files on your disk at once + load 150 icons. // FIXME: Does it really have to be a full, hard reload? Runtime updates should be made much cheaper. - // Clear whole list - for (int i = 0; i < _projects.size(); ++i) { - Item &project = _projects.write[i]; - CRASH_COND(project.control == nullptr); - memdelete(project.control); // Why not queue_free()? - } - _projects.clear(); - _last_clicked = ""; - _selected_project_paths.clear(); + if (ProjectManager::get_singleton()->is_initialized()) { + // Clear whole list + for (int i = 0; i < _projects.size(); ++i) { + Item &project = _projects.write[i]; + CRASH_COND(project.control == nullptr); + memdelete(project.control); // Why not queue_free()? + } - List<String> sections; - _config.load(_config_path); - _config.get_sections(§ions); + _projects.clear(); + _last_clicked = ""; + _selected_project_paths.clear(); - for (const String &path : sections) { - bool favorite = _config.get_value(path, "favorite", false); - _projects.push_back(load_project_data(path, favorite)); + load_project_list(); } // Create controls @@ -590,7 +586,21 @@ void ProjectList::find_projects_multiple(const PackedStringArray &p_paths) { } save_config(); - update_project_list(); + + if (ProjectManager::get_singleton()->is_initialized()) { + update_project_list(); + } +} + +void ProjectList::load_project_list() { + List<String> sections; + _config.load(_config_path); + _config.get_sections(§ions); + + for (const String &path : sections) { + bool favorite = _config.get_value(path, "favorite", false); + _projects.push_back(load_project_data(path, favorite)); + } } void ProjectList::_scan_folder_recursive(const String &p_path, List<String> *r_projects) { diff --git a/editor/project_manager/project_list.h b/editor/project_manager/project_list.h index 86f1f13bd8..981df0f3a0 100644 --- a/editor/project_manager/project_list.h +++ b/editor/project_manager/project_list.h @@ -220,6 +220,7 @@ public: // Project list updates. + void load_project_list(); void update_project_list(); void sort_projects(); int get_project_count() const; |