diff --git a/src/Assets/CubeMapAsset.cpp b/src/Assets/CubeMapAsset.cpp index ff7a3027..53f9413f 100644 --- a/src/Assets/CubeMapAsset.cpp +++ b/src/Assets/CubeMapAsset.cpp @@ -47,6 +47,6 @@ void CubeMapAsset::loadGPUPart() { surfaces[4]->pixels, surfaces[5]->pixels); for (int i = 0; i < 6; i++) { - delete surfaces[i]; + SDL_FreeSurface(surfaces[i]); } } \ No newline at end of file diff --git a/src/Assets/TextureAsset.cpp b/src/Assets/TextureAsset.cpp index 867505ee..84ec0bf6 100644 --- a/src/Assets/TextureAsset.cpp +++ b/src/Assets/TextureAsset.cpp @@ -178,5 +178,7 @@ void TextureAsset::getPossibleTexturesList(const AssetManager::AvailableAssetsNo } TextureAsset::~TextureAsset() { + if (cpuSurface) + SDL_FreeSurface(cpuSurface); //std::cout << "Texture asset deleted: " << name[0] << std::endl; } diff --git a/src/Editor/Editor.cpp b/src/Editor/Editor.cpp index 6233dfd6..4d92932e 100644 --- a/src/Editor/Editor.cpp +++ b/src/Editor/Editor.cpp @@ -888,7 +888,9 @@ void Editor::renderEditor() { entry.first->running = false; VisibilityRequest::condition.signalWaiting(); SDL_WaitThread(entry.second, nullptr); - world->visibilityThreadPool.erase(entry.first); + auto visRequest = entry.first; + world->visibilityThreadPool.erase(visRequest); + delete visRequest; } } } diff --git a/src/GameObjects/Light.h b/src/GameObjects/Light.h index ab1fcebf..b171eb0e 100644 --- a/src/GameObjects/Light.h +++ b/src/GameObjects/Light.h @@ -173,6 +173,15 @@ class Light : public GameObject, public CameraAttachment { } } + ~Light() { + for (auto cam: directionalCameras) { + delete cam; + } + for (auto cam: cubeCameras) { + delete cam; + } + } + /************Game Object methods **************/ uint32_t getWorldObjectID() const override { diff --git a/src/World.cpp b/src/World.cpp index 655e71c8..83172fb6 100755 --- a/src/World.cpp +++ b/src/World.cpp @@ -1194,7 +1194,20 @@ World::~World() { delete editorPlayer; delete menuPlayer; + delete apiGUILayer; + delete renderCounts; + delete fpsCounter; + delete cursor; + delete debugOutputGUI; + delete imgGuiHelper; + + for (auto &item: visibilityThreadPool) { + delete item.first; + if (item.second) { + SDL_WaitThread(item.second, NULL); + } + } } bool World::addModelToWorld(Model *xmlModel) {