From 6e3c766749b1cff11e06aea87385871b47592c29 Mon Sep 17 00:00:00 2001 From: hiker Date: Thu, 27 Nov 2014 15:36:56 +1100 Subject: [PATCH] Minor improvements to fix for #1713. --- lib/irrlicht/include/IReferenceCounted.h | 9 +++++++++ src/guiengine/scalable_font.hpp | 4 +--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/irrlicht/include/IReferenceCounted.h b/lib/irrlicht/include/IReferenceCounted.h index 8a551e8c4..35a2ccb3e 100644 --- a/lib/irrlicht/include/IReferenceCounted.h +++ b/lib/irrlicht/include/IReferenceCounted.h @@ -135,6 +135,15 @@ namespace irr return ReferenceCounter; } + //! Sets the reference count. + /** Use with extreme caution, since using it incorrectly results in memory + corruption or memory leaks. This method is only implemented for 'hollow' + copies of ScalableFont (an STK extention). */ + void setReferenceCount(s32 n) + { + ReferenceCounter = n; + } + //! Returns the debug name of the object. /** The Debugname may only be set and changed by the object itself. This method should only be used in Debug mode. diff --git a/src/guiengine/scalable_font.hpp b/src/guiengine/scalable_font.hpp index d186fec23..612536a99 100644 --- a/src/guiengine/scalable_font.hpp +++ b/src/guiengine/scalable_font.hpp @@ -97,9 +97,7 @@ public: { ScalableFont* out = new ScalableFont(*this); out->m_is_hollow_copy = true; - //FIXME: test only. Reset the reference counter of the copy to 1 - while (out->getReferenceCount() > 1) - out->drop(); + out->setReferenceCount(1); return out; }