From: JDCodeIt Date: Mon, 30 Apr 2018 17:14:28 +0000 (-0600) Subject: Global new() or grab() to be managed in constuctor only (#7235 partial) (#7236) X-Git-Tag: 5.0.0~424 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=5862d9e482f9b263df2a01ef6f5c4c5bcbef91bd;p=oweals%2Fminetest.git 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. --- diff --git a/src/wieldmesh.cpp b/src/wieldmesh.cpp index 7414701b7..7791a5a92 100644 --- a/src/wieldmesh.cpp +++ b/src/wieldmesh.cpp @@ -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