diff --git a/src/framework/core/logger.h b/src/framework/core/logger.h index fb229cf7..e5bf329c 100644 --- a/src/framework/core/logger.h +++ b/src/framework/core/logger.h @@ -2,6 +2,7 @@ #define LOGGER_H #include "../util/tools.h" +#include "../const.h" #include #include diff --git a/src/framework/graphics/animatedtexture.cpp b/src/framework/graphics/animatedtexture.cpp index c6edadbd..93519ea3 100644 --- a/src/framework/graphics/animatedtexture.cpp +++ b/src/framework/graphics/animatedtexture.cpp @@ -28,7 +28,6 @@ AnimatedTexture::AnimatedTexture(int width, int height, int channels, int numFra AnimatedTexture::~AnimatedTexture() { - assert(!g_graphics.isDrawing()); glDeleteTextures(m_numFrames, &m_framesTextureId[0]); m_textureId = 0; } @@ -48,7 +47,10 @@ void AnimatedTexture::processAnimation() if(m_currentFrame >= m_numFrames) m_currentFrame = 0; m_textureId = m_framesTextureId[m_currentFrame]; - AnimatedTexturePtr me = std::static_pointer_cast(shared_from_this()); - if(me.use_count() > 1) - g_dispatcher.scheduleEvent(std::bind(&AnimatedTexture::processAnimation, me), m_framesDelay[m_currentFrame]); + + AnimatedTexturePtr self = asAnimatedTexture(); + + // continue to animate only if something still referencing this texture + if(self.use_count() > 1) + g_dispatcher.scheduleEvent(std::bind(&AnimatedTexture::processAnimation, self), m_framesDelay[m_currentFrame]); } diff --git a/src/framework/graphics/animatedtexture.h b/src/framework/graphics/animatedtexture.h index 29bf7aad..5b2f13eb 100644 --- a/src/framework/graphics/animatedtexture.h +++ b/src/framework/graphics/animatedtexture.h @@ -12,6 +12,8 @@ public: void enableBilinearFilter(); void processAnimation(); + AnimatedTexturePtr asAnimatedTexture() { return std::static_pointer_cast(shared_from_this()); } + private: std::vector m_framesTextureId; std::vector m_framesDelay; @@ -20,7 +22,4 @@ private: int m_lastAnimCheckTicks; }; -typedef std::shared_ptr AnimatedTexturePtr; -typedef std::weak_ptr AnimatedTextureWeakPtr; - #endif diff --git a/src/framework/graphics/declarations.h b/src/framework/graphics/declarations.h index ede66004..af5a9e71 100644 --- a/src/framework/graphics/declarations.h +++ b/src/framework/graphics/declarations.h @@ -4,6 +4,7 @@ #include class Texture; +class AnimatedTexture; class Font; class Image; class BorderImage; @@ -12,6 +13,7 @@ class FrameBuffer; typedef std::weak_ptr TextureWeakPtr; typedef std::shared_ptr TexturePtr; +typedef std::shared_ptr AnimatedTexturePtr; typedef std::shared_ptr FontPtr; typedef std::shared_ptr ImagePtr; typedef std::shared_ptr BorderImagePtr; diff --git a/src/framework/luascript/luabinder.h b/src/framework/luascript/luabinder.h index 89e137fe..2df92066 100644 --- a/src/framework/luascript/luabinder.h +++ b/src/framework/luascript/luabinder.h @@ -5,11 +5,11 @@ #include "luainterface.h" #include "luaexception.h" -/// This namespace contains some dirty metaprogamming with C++0x features +/// This namespace contains some dirty metaprogamming that uses a lot of C++0x features /// The purpose here is to create templates that can bind any function from C++ /// and expose in lua environment. This is done combining variadic templates, /// lambdas, tuples and some type traits features from the new C++0x standard to create -/// templates that can detect functions arguments to generate a lambdas. These lambdas +/// templates that can detect functions's arguments and then generate lambdas. These lambdas /// pops arguments from lua stack, call the bound C++ function and then /// pushes the result to lua. namespace luabinder