Skip to content

Commit

Permalink
Merge pull request #152 from reglnk/master
Browse files Browse the repository at this point in the history
Fix some memory leaks
  • Loading branch information
enginmanap authored Nov 28, 2024
2 parents 25775be + 06c0b6b commit 8ad4ad1
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Assets/CubeMapAsset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}
2 changes: 2 additions & 0 deletions src/Assets/TextureAsset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
4 changes: 3 additions & 1 deletion src/Editor/Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/GameObjects/Light.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 13 additions & 0 deletions src/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 8ad4ad1

Please sign in to comment.