leaks fix (valgrind full leak check)

This commit is contained in:
MihailRis
2024-04-30 02:49:12 +03:00
parent bcf2f5029d
commit f8289a5d78
5 changed files with 17 additions and 19 deletions
+2
View File
@@ -172,8 +172,10 @@ Engine::~Engine() {
content.reset(); content.reset();
assets.reset(); assets.reset();
gui.reset(); gui.reset();
logger.info() << "gui finished";
audio::close(); audio::close();
scripting::close(); scripting::close();
logger.info() << "scripting finished";
Window::terminate(); Window::terminate();
logger.info() << "engine finished"; logger.info() << "engine finished";
} }
+1
View File
@@ -73,6 +73,7 @@ void Shader::uniform3f(const std::string& name, glm::vec3 xyz){
inline auto shader_deleter = [](GLuint* shader) { inline auto shader_deleter = [](GLuint* shader) {
glDeleteShader(*shader); glDeleteShader(*shader);
delete shader;
}; };
inline const uint GL_LOG_LEN = 512; inline const uint GL_LOG_LEN = 512;
+1
View File
@@ -396,6 +396,7 @@ void lua::LuaState::removeEnvironment(int id) {
} }
lua_pushnil(L); lua_pushnil(L);
setglobal(envName(id)); setglobal(envName(id));
logger.info() << "removed environment " << envName(id);
} }
void lua::LuaState::dumpStack() { void lua::LuaState::dumpStack() {
+8 -16
View File
@@ -2,18 +2,13 @@
#include "../voxels/WorldGenerator.h" #include "../voxels/WorldGenerator.h"
#include "../voxels/FlatWorldGenerator.h" #include "../voxels/FlatWorldGenerator.h"
#include "../content/Content.h" #include "../content/Content.h"
#include <vector>
#include <map>
#include <string>
#include <iostream> #include <iostream>
std::vector<std::string> WorldGenerators::getGeneratorsIDs() { std::vector<std::string> WorldGenerators::getGeneratorsIDs() {
std::vector<std::string> ids; std::vector<std::string> ids;
for (auto& entry : generators) {
for(std::map<std::string, gen_constructor>::iterator it = generators.begin(); it != generators.end(); ++it) { ids.push_back(entry.first);
ids.push_back(it->first);
} }
return ids; return ids;
} }
@@ -21,13 +16,10 @@ std::string WorldGenerators::getDefaultGeneratorID() {
return "core:default"; return "core:default";
} }
WorldGenerator* WorldGenerators::createGenerator(std::string id, const Content* content) { std::unique_ptr<WorldGenerator> WorldGenerators::createGenerator(std::string id, const Content* content) {
for(std::map<std::string, gen_constructor>::iterator it = generators.begin(); it != generators.end(); ++it) { auto found = generators.find(id);
if(id == it->first) { if (found == generators.end()) {
return (WorldGenerator*) it->second(content); throw std::runtime_error("unknown generator id: "+id);
}
} }
return std::unique_ptr<WorldGenerator>(found->second(content));
std::cerr << "unknown generator id: " << id << std::endl; }
return nullptr;
}
+5 -3
View File
@@ -11,7 +11,7 @@ typedef WorldGenerator* (*gen_constructor) (const Content*);
class WorldGenerators { class WorldGenerators {
static inline std::map<std::string, gen_constructor> generators = *(new std::map<std::string, gen_constructor>); static inline std::map<std::string, gen_constructor> generators;
public: public:
template <typename T> template <typename T>
@@ -21,7 +21,9 @@ public:
static std::string getDefaultGeneratorID(); static std::string getDefaultGeneratorID();
static WorldGenerator* createGenerator(std::string id, const Content* content); static std::unique_ptr<WorldGenerator> createGenerator(
std::string id, const Content* content
);
}; };
template <typename T> template <typename T>
@@ -33,4 +35,4 @@ void WorldGenerators::addGenerator(std::string id) {
}; };
} }
#endif /* WORLD_WORLDGENERATORS_H_ */ #endif /* WORLD_WORLDGENERATORS_H_ */