mirror of
https://github.com/leozide/leocad.git
synced 2026-07-27 19:56:49 +00:00
Fixed race condition where the main thread can upload a texture while it's being loaded. Fixes #1011.
This commit is contained in:
+11
-3
@@ -176,9 +176,13 @@ bool lcTexture::Load(const QString& FileName, int Flags)
|
||||
|
||||
if (!Image.FileLoad(FileName))
|
||||
return false;
|
||||
|
||||
|
||||
mLoading = true;
|
||||
|
||||
SetImage(std::move(Image), Flags);
|
||||
|
||||
mLoading = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -188,9 +192,13 @@ bool lcTexture::Load(lcMemFile& File, int Flags)
|
||||
|
||||
if (!Image.FileLoad(File))
|
||||
return false;
|
||||
|
||||
|
||||
mLoading = true;
|
||||
|
||||
SetImage(std::move(Image), Flags);
|
||||
|
||||
|
||||
mLoading = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -67,7 +67,7 @@ public:
|
||||
|
||||
bool NeedsUpload() const
|
||||
{
|
||||
return mTexture == 0 && !mImages.empty();
|
||||
return !mLoading && mTexture == 0 && !mImages.empty();
|
||||
}
|
||||
|
||||
int GetFlags() const
|
||||
@@ -99,6 +99,7 @@ protected:
|
||||
QAtomicInt mRefCount;
|
||||
std::vector<Image> mImages;
|
||||
int mFlags;
|
||||
bool mLoading = false;
|
||||
};
|
||||
|
||||
lcTexture* lcLoadTexture(const QString& FileName, int Flags);
|
||||
|
||||
Reference in New Issue
Block a user