Author: Carlos Lopez <[email protected]>
Date:   Mon Mar  4 17:41:59 2013 +0100

Redefine clear() member to take care on destroy the references to the cairo 
surfaces. Don't directly call the resize member without have cleared it before

---

 synfig-studio/src/gui/preview.cpp |   10 ++++++++++
 synfig-studio/src/gui/preview.h   |    7 ++++---
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/synfig-studio/src/gui/preview.cpp 
b/synfig-studio/src/gui/preview.cpp
index f641757..060b1b2 100644
--- a/synfig-studio/src/gui/preview.cpp
+++ b/synfig-studio/src/gui/preview.cpp
@@ -280,6 +280,7 @@ void studio::Preview::render()
                target->set_rend_desc(&desc);
 
                //... first we must clear our current selves of space
+               clear();
                frames.resize(0);
 
                //now tell it to go... with inherited prog. reporting...
@@ -290,6 +291,15 @@ void studio::Preview::render()
        }
 }
 
+void studio::Preview::clear()
+{
+       FlipBook::iterator it;
+       for(it=frames.begin(); it!=frames.end(); it++)
+               cairo_surface_destroy(it->surface);
+       frames.clear();
+}
+
+
 static void free_guint8(const guint8 *mem)
 {
        free((void*)mem);
diff --git a/synfig-studio/src/gui/preview.h b/synfig-studio/src/gui/preview.h
index 6484b5a..23be447 100644
--- a/synfig-studio/src/gui/preview.h
+++ b/synfig-studio/src/gui/preview.h
@@ -158,9 +158,10 @@ public:
        FlipBook::const_iterator        begin() const {return frames.begin();}
        FlipBook::const_iterator        end() const       {return frames.end();}
        void push_back(FlipbookElem fe) { frames.push_back(fe); }
-
-       void clear() {frames.clear();}
-
+       // Used to clear the FlipBook. Do not use directly the 
std::vector<>::clear member
+       // because the cairo_surface_t* wouldn't be destroyed.
+       void clear();
+       
        unsigned int                            numframes() const  {return 
frames.size();}
 
        void render();


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Synfig-devl mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synfig-devl

Reply via email to