Fixed an issue where the application shutdown was not always clean

This commit is contained in:
Leon Styhre 2023-11-10 20:42:14 +01:00
parent 54cf23b2d7
commit fed4dda4ac
4 changed files with 11 additions and 1 deletions

View file

@ -873,6 +873,7 @@ int main(int argc, char* argv[])
delete window->peekGui();
window->deinit();
TextureResource::setExit();
CollectionSystemsManager::getInstance()->deinit(true);
SystemData::deleteSystems();
NavigationSounds::getInstance().deinit();

View file

@ -177,7 +177,7 @@ void TextureLoader::threadProc()
}
}
// Queue has been released here but we might have a texture to process.
while (textureData) {
while (!mExit && textureData) {
textureData->load();
// See if there is another item in the queue.

View file

@ -29,6 +29,7 @@ public:
void load(std::shared_ptr<TextureData> textureData);
void remove(std::shared_ptr<TextureData> textureData);
void setExit() { mExit = true; }
size_t getQueueSize();
private:
@ -83,6 +84,12 @@ public:
size_t getQueueSize();
// Load a texture, freeing resources as necessary to make space.
void load(std::shared_ptr<TextureData> tex, bool block = false);
// Make sure that threadProc() does not continue to run during application shutdown.
void setExit()
{
if (mLoader)
mLoader->setExit();
}
private:
std::list<std::shared_ptr<TextureData>> mTextures;

View file

@ -80,6 +80,8 @@ public:
// Returns the number of bytes that would be used if all textures were in memory.
static size_t getTotalTextureSize();
static void setExit() { sTextureDataManager.setExit(); }
protected:
TextureResource(const std::string& path,
float tileWidth,