Optimization and tweaks
This commit is contained in:
@@ -38,9 +38,10 @@ void Asset::OnDeleteObject()
|
||||
if (!IsInternalType())
|
||||
Content::AssetDisposing(this);
|
||||
|
||||
// Cache data
|
||||
const bool wasMarkedToDelete = _deleteFileOnUnload != 0;
|
||||
#if USE_EDITOR
|
||||
const String path = wasMarkedToDelete ? GetPath() : String::Empty;
|
||||
#endif
|
||||
const Guid id = GetID();
|
||||
|
||||
// Fire unload event (every object referencing this asset or it's data should release reference so later actions are safe)
|
||||
@@ -66,7 +67,7 @@ void Asset::OnDeleteObject()
|
||||
// Base (after it `this` is invalid)
|
||||
ManagedScriptingObject::OnDeleteObject();
|
||||
|
||||
// Check if asset was marked to delete
|
||||
#if USE_EDITOR
|
||||
if (wasMarkedToDelete)
|
||||
{
|
||||
LOG(Info, "Deleting asset '{0}':{1}.", path, id.ToString());
|
||||
@@ -77,6 +78,7 @@ void Asset::OnDeleteObject()
|
||||
// Delete file
|
||||
Content::deleteFileSafety(path, id);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Asset::CreateManaged()
|
||||
@@ -131,6 +133,20 @@ void Asset::ChangeID(const Guid& newId)
|
||||
CRASH;
|
||||
}
|
||||
|
||||
bool Asset::LastLoadFailed() const
|
||||
{
|
||||
return _loadFailed != 0;
|
||||
}
|
||||
|
||||
#if USE_EDITOR
|
||||
|
||||
bool Asset::ShouldDeleteFileOnUnload() const
|
||||
{
|
||||
return _deleteFileOnUnload != 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void Asset::Reload()
|
||||
{
|
||||
// It's better to call it from the main thread
|
||||
@@ -335,7 +351,7 @@ void Asset::startLoading()
|
||||
bool Asset::onLoad(LoadAssetTask* task)
|
||||
{
|
||||
// It may fail when task is cancelled and new one is created later (don't crash but just end with an error)
|
||||
if (task->GetAsset() != this || _loadingTask == nullptr)
|
||||
if (task->Asset.Get() != this || _loadingTask == nullptr)
|
||||
return true;
|
||||
|
||||
Locker.Lock();
|
||||
|
||||
Reference in New Issue
Block a user