== Sculpt ==
authorNicholas Bishop <nicholasbishop@gmail.com>
Wed, 26 Dec 2007 23:08:00 +0000 (23:08 +0000)
committerNicholas Bishop <nicholasbishop@gmail.com>
Wed, 26 Dec 2007 23:08:00 +0000 (23:08 +0000)
Fixed a memory leak when using the interactive brush resize tool.

source/blender/blenkernel/BKE_sculpt.h
source/blender/blenkernel/intern/scene.c
source/blender/blenloader/intern/readfile.c
source/blender/include/BDR_sculptmode.h
source/blender/src/sculptmode.c

index 61b8dc071aa2cfd3a600bf755aec994179181ea6..d539bcf5e8c6df501dcc42d31ad449e724da324b 100644 (file)
  * ***** END GPL LICENSE BLOCK *****
  */
 
+#ifndef BKE_SCULPT_H
+#define BKE_SCULPT_H
+
+struct NumInput;
+struct Scene;
+struct SculptData;
+struct SculptSession;
+
+typedef enum PropsetMode {
+       PropsetNone = 0,
+       PropsetSize,
+       PropsetStrength,
+       PropsetTexRot
+} PropsetMode;
+
+typedef struct PropsetData {
+       PropsetMode mode;
+       unsigned int tex;
+       short origloc[2];
+       float *texdata;
+       
+       short origsize;
+       char origstrength;
+       float origtexrot;
+       
+       struct NumInput *num;
+} PropsetData;
+
 typedef struct SculptSession {
        struct ProjVert *projverts;
 
@@ -62,3 +90,4 @@ void sculptsession_free(struct Scene *sce);
 void sculpt_vertexusers_free(struct SculptSession *ss);
 void sculpt_reset_curve(struct SculptData *sd);
 
+#endif
index 88dca65f594dc46f9470319c60838577f6551969..47640ad07ae4c909b7d822a4d31cdb9209f17975 100644 (file)
@@ -659,6 +659,15 @@ void sculptsession_free(Scene *sce)
                        MEM_freeN(ss->projverts);
                if(ss->mats)
                        MEM_freeN(ss->mats);
+
+               if(ss->propset) {
+                       if(ss->propset->texdata)
+                               MEM_freeN(ss->propset->texdata);
+                       if(ss->propset->num)
+                               MEM_freeN(ss->propset->num);
+                       MEM_freeN(ss->propset);
+               }
+
                sculpt_vertexusers_free(ss);
                if(ss->texcache)
                        MEM_freeN(ss->texcache);
index f8f0395300c52d3e67552a385df59277e7734868..043febbbc75b337e11427416eafe618067d53d6d 100644 (file)
 #include "BKE_sca.h" // for init_actuator
 #include "BKE_scene.h"
 #include "BKE_softbody.h"      // sbNew()
+#include "BKE_sculpt.h"
 #include "BKE_texture.h" // for open_plugin_tex
 #include "BKE_utildefines.h" // SWITCH_INT DATA ENDB DNA1 O_BINARY GLOB USER TEST REND
 #include "BKE_idprop.h"
index 884f1000b1fd132c501954ddf40d77035de8462e..e15c1fb706340f2b68e776a5d58a3ce38e73c6bc 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "DNA_listBase.h"
 #include "DNA_vec_types.h"
+#include "BKE_sculpt.h"
 #include "transform.h"
 
 struct uiBlock;
@@ -47,26 +48,6 @@ struct ScrArea;
 struct SculptData;
 struct SculptStroke;
 
-typedef enum PropsetMode {
-       PropsetNone = 0,
-       PropsetSize,
-       PropsetStrength,
-       PropsetTexRot
-} PropsetMode;
-
-typedef struct PropsetData {
-       PropsetMode mode;
-       unsigned int tex;
-       short origloc[2];
-       float *texdata;
-       
-       short origsize;
-       char origstrength;
-       float origtexrot;
-       
-       NumInput num;
-} PropsetData;
-
 struct SculptSession *sculpt_session(void);
 struct SculptData *sculpt_data(void);
 
index 64f9ad0283e67c8aa677eae44d2215fbe1524919..f3bfb64531552ab1fd4e43afa5f970cc5cec6346 100644 (file)
@@ -1313,6 +1313,7 @@ void sculptmode_propset_end(SculptSession *ss, int cancel)
                                set_tex_angle(pd->origtexrot);
                }
                glDeleteTextures(1, &pd->tex);
+               MEM_freeN(pd->num);
                MEM_freeN(pd->texdata);
                MEM_freeN(pd);
                ss->propset= NULL;
@@ -1353,7 +1354,9 @@ void sculptmode_propset_init(PropsetMode mode)
                
                sculptmode_propset_calctex();
                
-               pd->num.idx_max= 0;
+               if(!pd->num)
+                       pd->num = MEM_callocN(sizeof(NumInput), "propset numinput");
+               pd->num->idx_max= 0;
        }
 
        pd->mode= mode;
@@ -1391,11 +1394,11 @@ void sculptmode_propset(unsigned short event)
        BrushData *brush= sculptmode_brush();
        char valset= 0;
        
-       handleNumInput(&pd->num, event);
+       handleNumInput(pd->num, event);
        
-       if(hasNumInput(&pd->num)) {
+       if(hasNumInput(pd->num)) {
                float val;
-               applyNumInput(&pd->num, &val);
+               applyNumInput(pd->num, &val);
                if(pd->mode==PropsetSize)
                        brush->size= val;
                else if(pd->mode==PropsetStrength)
@@ -1409,7 +1412,7 @@ void sculptmode_propset(unsigned short event)
        switch(event) {
        case MOUSEX:
        case MOUSEY:
-               if(!hasNumInput(&pd->num)) {
+               if(!hasNumInput(pd->num)) {
                        char ctrl= G.qual & LR_CTRLKEY;
                        getmouseco_areawin(mouse);
                        tmp[0]= pd->origloc[0]-mouse[0];