Moved operations on blend file data from C++ class destructor to a specific method
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Sat, 2 Mar 2013 22:20:27 +0000 (22:20 +0000)
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Sat, 2 Mar 2013 22:20:27 +0000 (22:20 +0000)
for releasing resources.  Based on review comment from Campbell.

source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h
source/blender/freestyle/intern/stroke/Canvas.cpp
source/blender/freestyle/intern/stroke/StyleModule.h

index 4c6f7e02722f1b866c2af5790644a60ca9bbe1e3..7a1ce0a082bb83f5a3b45018433f21c6d9ccf7e4 100644 (file)
@@ -50,6 +50,10 @@ public:
        }
 
        virtual ~BlenderStyleModule()
+       {
+       }
+
+       virtual void close()
        {
                BKE_text_unlink(G.main, _text);
                BKE_libblock_free(&G.main->text, _text);
index 4427192a7b05eae6d26df48a5d7befe79277f5a4..3fd2f9252d9d96c0201527a0c216f8d01e8cc5b5 100644 (file)
@@ -140,7 +140,6 @@ void Canvas::postDraw()
        update();
 }
 
-
 void Canvas::Clear()
 {
        if (!_Layers.empty()) {
@@ -153,8 +152,10 @@ void Canvas::Clear()
 
        if (!_StyleModules.empty()) {
                for (deque<StyleModule*>::iterator s = _StyleModules.begin(), send = _StyleModules.end(); s != send; ++s) {
-                       if (*s)
+                       if (*s) {
+                               (*s)->close();
                                delete (*s);
+                       }
                }
                _StyleModules.clear();
        }
@@ -234,7 +235,6 @@ void Canvas::RemoveStyleModule(unsigned index)
        }
 }
 
-
 void Canvas::SwapStyleModules(unsigned i1, unsigned i2)
 {
        StyleModule *tmp;
index 12f645f125b0452e5e6482fe5338e2ca3e4c3766..3d053f9b4e1f53d663eae8aa628f3f0d3e90c5cf 100644 (file)
@@ -98,6 +98,8 @@ public:
                return sl;
        }
 
+       virtual void close() {}
+
 protected:
        virtual int interpret()
        {