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

View File

@ -172,8 +172,10 @@ Engine::~Engine() {
content.reset();
assets.reset();
gui.reset();
logger.info() << "gui finished";
audio::close();
scripting::close();
logger.info() << "scripting finished";
Window::terminate();
logger.info() << "engine finished";
}

View File

@ -73,6 +73,7 @@ void Shader::uniform3f(const std::string& name, glm::vec3 xyz){
inline auto shader_deleter = [](GLuint* shader) {
glDeleteShader(*shader);
delete shader;
};
inline const uint GL_LOG_LEN = 512;

View File

@ -396,6 +396,7 @@ void lua::LuaState::removeEnvironment(int id) {
}
lua_pushnil(L);
setglobal(envName(id));
logger.info() << "removed environment " << envName(id);
}
void lua::LuaState::dumpStack() {

View File

@ -2,18 +2,13 @@
#include "../voxels/WorldGenerator.h"
#include "../voxels/FlatWorldGenerator.h"
#include "../content/Content.h"
#include <vector>
#include <map>
#include <string>
#include <iostream>
std::vector<std::string> WorldGenerators::getGeneratorsIDs() {
std::vector<std::string> ids;
for(std::map<std::string, gen_constructor>::iterator it = generators.begin(); it != generators.end(); ++it) {
ids.push_back(it->first);
for (auto& entry : generators) {
ids.push_back(entry.first);
}
return ids;
}
@ -21,13 +16,10 @@ std::string WorldGenerators::getDefaultGeneratorID() {
return "core:default";
}
WorldGenerator* WorldGenerators::createGenerator(std::string id, const Content* content) {
for(std::map<std::string, gen_constructor>::iterator it = generators.begin(); it != generators.end(); ++it) {
if(id == it->first) {
return (WorldGenerator*) it->second(content);
}
std::unique_ptr<WorldGenerator> WorldGenerators::createGenerator(std::string id, const Content* content) {
auto found = generators.find(id);
if (found == generators.end()) {
throw std::runtime_error("unknown generator id: "+id);
}
std::cerr << "unknown generator id: " << id << std::endl;
return nullptr;
}
return std::unique_ptr<WorldGenerator>(found->second(content));
}

View File

@ -11,7 +11,7 @@ typedef WorldGenerator* (*gen_constructor) (const Content*);
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:
template <typename T>
@ -21,7 +21,9 @@ public:
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>
@ -33,4 +35,4 @@ void WorldGenerators::addGenerator(std::string id) {
};
}
#endif /* WORLD_WORLDGENERATORS_H_ */
#endif /* WORLD_WORLDGENERATORS_H_ */