mirror of
				https://github.com/godotengine/godot.git
				synced 2025-10-31 13:41:03 +00:00 
			
		
		
		
	Fix Segmentation fault and reduce memory consumption
(cherry picked from commit a156b7976d)
			
			
This commit is contained in:
		
							parent
							
								
									6c71289432
								
							
						
					
					
						commit
						6afcc72465
					
				
					 2 changed files with 7 additions and 19 deletions
				
			
		|  | @ -1609,40 +1609,28 @@ void ProjectManager::_show_project(const String &p_path) { | ||||||
| 	OS::get_singleton()->shell_open(String("file://") + p_path); | 	OS::get_singleton()->shell_open(String("file://") + p_path); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ProjectManager::_scan_dir(DirAccess *da, float pos, float total, List<String> *r_projects) { | void ProjectManager::_scan_dir(const String &path, List<String> *r_projects) { | ||||||
| 
 | 	DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); | ||||||
| 	List<String> subdirs; | 	da->change_dir(path); | ||||||
| 	da->list_dir_begin(); | 	da->list_dir_begin(); | ||||||
| 	String n = da->get_next(); | 	String n = da->get_next(); | ||||||
| 	while (n != String()) { | 	while (n != String()) { | ||||||
| 		if (da->current_is_dir() && !n.begins_with(".")) { | 		if (da->current_is_dir() && !n.begins_with(".")) { | ||||||
| 			subdirs.push_front(n); | 			_scan_dir(da->get_current_dir().plus_file(n), r_projects); | ||||||
| 		} else if (n == "project.godot") { | 		} else if (n == "project.godot") { | ||||||
| 			r_projects->push_back(da->get_current_dir()); | 			r_projects->push_back(da->get_current_dir()); | ||||||
| 		} | 		} | ||||||
| 		n = da->get_next(); | 		n = da->get_next(); | ||||||
| 	} | 	} | ||||||
| 	da->list_dir_end(); | 	da->list_dir_end(); | ||||||
| 	int m = 0; | 	memdelete(da); | ||||||
| 	for (List<String>::Element *E = subdirs.front(); E; E = E->next()) { |  | ||||||
| 
 |  | ||||||
| 		da->change_dir(E->get()); |  | ||||||
| 
 |  | ||||||
| 		float slice = total / subdirs.size(); |  | ||||||
| 		_scan_dir(da, pos + slice * m, slice, r_projects); |  | ||||||
| 		da->change_dir(".."); |  | ||||||
| 		m++; |  | ||||||
| 	} |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ProjectManager::_scan_begin(const String &p_base) { | void ProjectManager::_scan_begin(const String &p_base) { | ||||||
| 
 | 
 | ||||||
| 	print_line("Scanning projects at: " + p_base); | 	print_line("Scanning projects at: " + p_base); | ||||||
| 	List<String> projects; | 	List<String> projects; | ||||||
| 	DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); | 	_scan_dir(p_base, &projects); | ||||||
| 	da->change_dir(p_base); |  | ||||||
| 	_scan_dir(da, 0, 1, &projects); |  | ||||||
| 	memdelete(da); |  | ||||||
| 	print_line("Found " + itos(projects.size()) + " projects."); | 	print_line("Found " + itos(projects.size()) + " projects."); | ||||||
| 
 | 
 | ||||||
| 	for (List<String>::Element *E = projects.front(); E; E = E->next()) { | 	for (List<String>::Element *E = projects.front(); E; E = E->next()) { | ||||||
|  |  | ||||||
|  | @ -102,7 +102,7 @@ class ProjectManager : public Control { | ||||||
| 	void _on_project_created(const String &dir); | 	void _on_project_created(const String &dir); | ||||||
| 	void _on_projects_updated(); | 	void _on_projects_updated(); | ||||||
| 	void _update_scroll_position(const String &dir); | 	void _update_scroll_position(const String &dir); | ||||||
| 	void _scan_dir(DirAccess *da, float pos, float total, List<String> *r_projects); | 	void _scan_dir(const String &path, List<String> *r_projects); | ||||||
| 
 | 
 | ||||||
| 	void _install_project(const String &p_zip_path, const String &p_title); | 	void _install_project(const String &p_zip_path, const String &p_title); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Nils ANDRÉ-CHANG
						Nils ANDRÉ-CHANG