Fix deadlock when hot-reloading scripts in Editor while Animation asset gets auto-saved
#3942
This commit is contained in:
@@ -691,11 +691,7 @@ Asset::LoadResult Animation::load()
|
||||
continue;
|
||||
}
|
||||
#if USE_EDITOR
|
||||
if (!_registeredForScriptingReload)
|
||||
{
|
||||
_registeredForScriptingReload = true;
|
||||
Level::ScriptsReloadStart.Bind<Animation, &Animation::OnScriptsReloadStart>(this);
|
||||
}
|
||||
_registerForScriptingReload = true;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -733,6 +729,7 @@ void Animation::unload(bool isReloading)
|
||||
{
|
||||
ScopeWriteLock systemScope(Animations::SystemLocker);
|
||||
#if USE_EDITOR
|
||||
_registerForScriptingReload = false;
|
||||
if (_registeredForScriptingReload)
|
||||
{
|
||||
_registeredForScriptingReload = false;
|
||||
@@ -752,6 +749,22 @@ void Animation::unload(bool isReloading)
|
||||
NestedAnims.Clear();
|
||||
}
|
||||
|
||||
#if USE_EDITOR
|
||||
|
||||
void Animation::onLoaded_MainThread()
|
||||
{
|
||||
if (_registerForScriptingReload && !_registeredForScriptingReload)
|
||||
{
|
||||
_registeredForScriptingReload = true;
|
||||
Level::ScriptsReloadStart.Bind<Animation, &Animation::OnScriptsReloadStart>(this);
|
||||
}
|
||||
_registerForScriptingReload = false;
|
||||
|
||||
BinaryAsset::onLoaded_MainThread();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
AssetChunksFlag Animation::getChunksToPreload() const
|
||||
{
|
||||
return GET_CHUNK_FLAG(0);
|
||||
|
||||
@@ -78,6 +78,7 @@ API_CLASS(NoSpawn) class FLAXENGINE_API Animation : public BinaryAsset
|
||||
|
||||
private:
|
||||
#if USE_EDITOR
|
||||
bool _registerForScriptingReload = false;
|
||||
bool _registeredForScriptingReload = false;
|
||||
void OnScriptsReloadStart();
|
||||
#endif
|
||||
@@ -163,5 +164,8 @@ protected:
|
||||
// [BinaryAsset]
|
||||
LoadResult load() override;
|
||||
void unload(bool isReloading) override;
|
||||
#if USE_EDITOR
|
||||
void onLoaded_MainThread() override;
|
||||
#endif
|
||||
AssetChunksFlag getChunksToPreload() const override;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user