=bmesh= fixed knifetool mem leak
authorJoseph Eagar <joeedh@gmail.com>
Thu, 12 May 2011 18:46:21 +0000 (18:46 +0000)
committerJoseph Eagar <joeedh@gmail.com>
Thu, 12 May 2011 18:46:21 +0000 (18:46 +0000)
source/blender/blenkernel/intern/editderivedbmesh.c
source/blender/editors/mesh/knifetool.c

index eb84bfd6c95a560bd16858abae7553bca74f8dfc..d1773632aeb445668923ff205a98213edfd9722c 100644 (file)
@@ -133,45 +133,6 @@ static void BMEdit_RecalcTesselation_intern(BMEditMesh *tm)
        
        if (tm->looptris) MEM_freeN(tm->looptris);
 
-#if 0 //simple quad/triangle code for performance testing purposes
-       looptris = MEM_callocN(sizeof(void*)*bm->totface*8, "looptris");
-
-       f = BMIter_New(&iter, bm, BM_FACES_OF_MESH, NULL);
-       for ( ; f; f=BMIter_Step(&iter)) {
-               EditVert *v, *lastv=NULL, *firstv=NULL;
-               EditEdge *e;
-               EditFace *efa;
-
-               /*don't consider two-edged faces*/
-               if (f->len < 3) continue;
-               
-               //BLI_array_growone(looptris);
-               //BLI_array_growone(looptris);
-               //BLI_array_growone(looptris);
-
-               looptris[i*3] = f->loopbase;
-               looptris[i*3+1] = f->loopbase->head.next;
-               looptris[i*3+2] = f->loopbase->head.next->next;
-               i++;
-
-               if (f->len > 3) {
-                       //BLI_array_growone(looptris);
-                       //BLI_array_growone(looptris);
-                       //BLI_array_growone(looptris);
-
-                       looptris[i*3] = f->loopbase;
-                       looptris[i*3+1] = f->loopbase->head.next->next;
-                       looptris[i*3+2] = f->loopbase->head.next->next->next;
-                       i++;
-               }
-
-       }
-
-       tm->tottri = i;
-       tm->looptris = looptris;
-       return;
-#endif
-
        f = BMIter_New(&iter, bm, BM_FACES_OF_MESH, NULL);
        for ( ; f; f=BMIter_Step(&iter)) {
                EditVert *v, *lastv=NULL, *firstv=NULL;
index c39f88bf19ba7b43e102d199025a17fdb1371787..db4dea15584f601647e609172348961895fe8e8c 100755 (executable)
@@ -886,7 +886,9 @@ static BMEdgeHit *knife_edge_tri_isect(knifetool_opdata *kcd, BMBVHTree *bmtree,
        if (results)
                MEM_freeN(results);
        
+       BLI_bvhtree_free(tree2);
        *count = BLI_array_count(edges);
+       
        return edges;
 }
 
@@ -1813,8 +1815,10 @@ static int knifetool_modal (bContext *C, wmOperator *op, wmEvent *event)
        }
        
        obedit = CTX_data_edit_object(C);
-       if (!obedit || obedit->type != OB_MESH || ((Mesh*)obedit->data)->edit_btmesh != kcd->em)
+       if (!obedit || obedit->type != OB_MESH || ((Mesh*)obedit->data)->edit_btmesh != kcd->em) {
+               knifetool_exit(C, op);
                return OPERATOR_FINISHED;
+       }
 
        view3d_operator_needs_opengl(C);