Skip to content

Commit

Permalink
Global new() or grab() to be managed in constuctor only (#7235 partia…
Browse files Browse the repository at this point in the history
…l) (#7236)

* g_extrusion_mesh_cache new() and grab() to be managed in constuctor only (#7235 partial)

This global was getting grab()-ed by each call to getItemMesh, incrementing its reference count. What was to be the final drop() in the destructor ended up with > 0 reference count, so memory not freed by Irrlicht.
  • Loading branch information
JDCodeIt authored and SmallJoker committed Apr 30, 2018
1 parent ba91624 commit 5862d9e
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/wieldmesh.cpp
Expand Up @@ -501,12 +501,8 @@ void getItemMesh(Client *client, const ItemStack &item, ItemMesh *result)
const ContentFeatures &f = ndef->get(def.name);
content_t id = ndef->getId(def.name);

if (!g_extrusion_mesh_cache) {
g_extrusion_mesh_cache = new ExtrusionMeshCache();
} else {
g_extrusion_mesh_cache->grab();
}

FATAL_ERROR_IF(!g_extrusion_mesh_cache, "Extrusion mesh cache is not yet initialized");

scene::SMesh *mesh = nullptr;

// Shading is on by default
Expand Down

0 comments on commit 5862d9e

Please sign in to comment.