Enforce Content:CloneAssetFile() running on the main thread, to avoid a bug that occurs when a particle emitter is created from one of the templates due to the creation coming from the content thread.
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
#include "Engine/Engine/EngineService.h"
|
#include "Engine/Engine/EngineService.h"
|
||||||
#include "Engine/Platform/FileSystem.h"
|
#include "Engine/Platform/FileSystem.h"
|
||||||
#include "Engine/Threading/Threading.h"
|
#include "Engine/Threading/Threading.h"
|
||||||
|
#include "Engine/Threading/MainThreadTask.h"
|
||||||
#include "Engine/Graphics/Graphics.h"
|
#include "Engine/Graphics/Graphics.h"
|
||||||
#include "Engine/Engine/Time.h"
|
#include "Engine/Engine/Time.h"
|
||||||
#include "Engine/Engine/Globals.h"
|
#include "Engine/Engine/Globals.h"
|
||||||
@@ -688,8 +689,27 @@ bool Content::FastTmpAssetClone(const StringView& path, String& resultPath)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class CloneAssetFileTask : public MainThreadTask
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
StringView dstPath;
|
||||||
|
StringView srcPath;
|
||||||
|
Guid dstId;
|
||||||
|
bool* output;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool Run() override
|
||||||
|
{
|
||||||
|
*output = Content::CloneAssetFile(dstPath, srcPath, dstId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
bool Content::CloneAssetFile(const StringView& dstPath, const StringView& srcPath, const Guid& dstId)
|
bool Content::CloneAssetFile(const StringView& dstPath, const StringView& srcPath, const Guid& dstId)
|
||||||
{
|
{
|
||||||
|
// Best to run this on the main thread to avoid clone conflicts.
|
||||||
|
if (IsInMainThread())
|
||||||
|
{
|
||||||
PROFILE_CPU();
|
PROFILE_CPU();
|
||||||
ASSERT(FileSystem::AreFilePathsEqual(srcPath, dstPath) == false && dstId.IsValid());
|
ASSERT(FileSystem::AreFilePathsEqual(srcPath, dstPath) == false && dstId.IsValid());
|
||||||
|
|
||||||
@@ -784,6 +804,21 @@ bool Content::CloneAssetFile(const StringView& dstPath, const StringView& srcPat
|
|||||||
storage->Reload();
|
storage->Reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CloneAssetFileTask* task = New<CloneAssetFileTask>();
|
||||||
|
task->dstId = dstId;
|
||||||
|
task->dstPath = dstPath;
|
||||||
|
task->srcPath = srcPath;
|
||||||
|
|
||||||
|
bool result = false;
|
||||||
|
task->output = &result;
|
||||||
|
task->Start();
|
||||||
|
task->Wait();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user