Fix accessing UID before first scan
This commit is contained in:
parent
36d90c73a8
commit
9457666bba
5 changed files with 115 additions and 9 deletions
|
|
@ -154,6 +154,19 @@ String ResourceUID::get_id_path(ID p_id) const {
|
|||
ERR_FAIL_COND_V_MSG(p_id == INVALID_ID, String(), "Invalid UID.");
|
||||
MutexLock l(mutex);
|
||||
const ResourceUID::Cache *cache = unique_ids.getptr(p_id);
|
||||
|
||||
#if TOOLS_ENABLED
|
||||
// On startup, the scan_for_uid_on_startup callback should be set and will
|
||||
// execute EditorFileSystem::scan_for_uid, which scans all project files
|
||||
// to reload the UID cache before the first scan.
|
||||
// Note: EditorFileSystem::scan_for_uid sets scan_for_uid_on_startup to nullptr
|
||||
// once the first scan_for_uid is complete.
|
||||
if (!cache && scan_for_uid_on_startup) {
|
||||
scan_for_uid_on_startup();
|
||||
cache = unique_ids.getptr(p_id);
|
||||
}
|
||||
#endif
|
||||
|
||||
ERR_FAIL_COND_V_MSG(!cache, String(), vformat("Unrecognized UID: \"%s\".", id_to_text(p_id)));
|
||||
const CharString &cs = cache->cs;
|
||||
return String::utf8(cs.ptr());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue