Fixed Crashing and edge cases
This commit is contained in:
parent
86abf8e5b7
commit
c19658a9dd
@ -164,7 +164,6 @@ void FileExplorer::Show(bool* p_open)
|
||||
entries.push_back(e);
|
||||
}
|
||||
|
||||
// Sort
|
||||
std::sort(entries.begin(), entries.end(), [&](auto &a, auto &b) {
|
||||
if (sortMode == 1) {
|
||||
bool da = a.is_directory(), db = b.is_directory();
|
||||
@ -231,7 +230,7 @@ void FileExplorer::Show(bool* p_open)
|
||||
break;
|
||||
}
|
||||
clicked = ImGui::Button(
|
||||
(std::string("##entry") + label).c_str(),
|
||||
(label + std::string("##entry") + label).c_str(),
|
||||
ImVec2(iconSize, iconSize));
|
||||
}
|
||||
|
||||
|
@ -792,14 +792,25 @@ void PrefabAssetInfo::ReloadFromYAML()
|
||||
|
||||
std::shared_ptr<Object> PrefabAssetInfo::Instantiate() const
|
||||
{
|
||||
if (!prefabYAML || !prefabYAML.IsMap())
|
||||
{
|
||||
Logger::LogError("[PrefabAsset] Cannot instantiate: prefab YAML is invalid.");
|
||||
if (!prefabYAML || !prefabYAML.IsMap()) {
|
||||
Logger::LogError("Cannot instantiate '%s': invalid YAML.", prefabName.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static thread_local std::unordered_set<uint64_t> s_instantiating;
|
||||
|
||||
if (!s_instantiating.insert(uaid).second) {
|
||||
Logger::LogError(
|
||||
"Recursive instantiation detected for prefab '%s' (UAID=%llu).",
|
||||
prefabName.c_str(), (unsigned long long)uaid
|
||||
);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto newObj = std::make_shared<Object>(prefabName);
|
||||
newObj->Load(prefabYAML);
|
||||
|
||||
s_instantiating.erase(uaid);
|
||||
return newObj;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user