Skip to content

Commit 5862d9e

Browse files
JDCodeItSmallJoker
authored andcommittedApr 30, 2018
Global new() or grab() to be managed in constuctor only (#7235 partial) (#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.
1 parent ba91624 commit 5862d9e

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed
 

‎src/wieldmesh.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -501,12 +501,8 @@ void getItemMesh(Client *client, const ItemStack &item, ItemMesh *result)
501501
const ContentFeatures &f = ndef->get(def.name);
502502
content_t id = ndef->getId(def.name);
503503

504-
if (!g_extrusion_mesh_cache) {
505-
g_extrusion_mesh_cache = new ExtrusionMeshCache();
506-
} else {
507-
g_extrusion_mesh_cache->grab();
508-
}
509-
504+
FATAL_ERROR_IF(!g_extrusion_mesh_cache, "Extrusion mesh cache is not yet initialized");
505+
510506
scene::SMesh *mesh = nullptr;
511507

512508
// Shading is on by default

0 commit comments

Comments
 (0)
Please sign in to comment.