Fix deadlock regression from fd679f0af5 when applying Game Settings itself
This commit is contained in:
@@ -227,7 +227,7 @@ protected:
|
||||
|
||||
bool onLoad(LoadAssetTask* task);
|
||||
void onLoaded();
|
||||
void onLoaded_MainThread();
|
||||
virtual void onLoaded_MainThread();
|
||||
virtual void onUnload_MainThread();
|
||||
#if USE_EDITOR
|
||||
virtual void onRename(const StringView& newPath) = 0;
|
||||
|
||||
@@ -367,6 +367,20 @@ void JsonAsset::unload(bool isReloading)
|
||||
JsonAssetBase::unload(isReloading);
|
||||
}
|
||||
|
||||
void JsonAsset::onLoaded_MainThread()
|
||||
{
|
||||
JsonAssetBase::onLoaded_MainThread();
|
||||
|
||||
// Special case for Settings assets to flush them after edited and saved in Editor
|
||||
const StringAsANSI<> dataTypeNameAnsi(DataTypeName.Get(), DataTypeName.Length());
|
||||
const auto typeHandle = Scripting::FindScriptingType(StringAnsiView(dataTypeNameAnsi.Get(), DataTypeName.Length()));
|
||||
if (Instance && typeHandle && typeHandle.IsSubclassOf(SettingsBase::TypeInitializer) && _isAfterReload)
|
||||
{
|
||||
_isAfterReload = false;
|
||||
((SettingsBase*)Instance)->Apply();
|
||||
}
|
||||
}
|
||||
|
||||
bool JsonAsset::CreateInstance()
|
||||
{
|
||||
ScopeLock lock(Locker);
|
||||
@@ -409,13 +423,6 @@ bool JsonAsset::CreateInstance()
|
||||
}
|
||||
}
|
||||
|
||||
// Special case for Settings assets to flush them after edited and saved in Editor
|
||||
if (typeHandle && typeHandle.IsSubclassOf(SettingsBase::TypeInitializer) && _isAfterReload)
|
||||
{
|
||||
_isAfterReload = false;
|
||||
((SettingsBase*)Instance)->Apply();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -150,6 +150,7 @@ protected:
|
||||
// [JsonAssetBase]
|
||||
LoadResult loadAsset() override;
|
||||
void unload(bool isReloading) override;
|
||||
void onLoaded_MainThread() override;
|
||||
|
||||
private:
|
||||
bool CreateInstance();
|
||||
|
||||
Reference in New Issue
Block a user