Fixed race condition where the main thread can upload a texture while it's being loaded. Fixes #1011.

This commit is contained in:
Leonardo Zide
2026-03-08 17:32:23 -07:00
parent 62e5bb4867
commit da29df623b
2 changed files with 13 additions and 4 deletions
+11 -3
View File
@@ -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
View File
@@ -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);