Commit a3db4c0b authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

fixed remaining memory leaks when instantiating/deleting abstractions (see previous commit).

parent ab88c5bc
...@@ -872,11 +872,14 @@ int glist_getfont(t_glist *x) ...@@ -872,11 +872,14 @@ int glist_getfont(t_glist *x)
void canvas_free(t_canvas *x) void canvas_free(t_canvas *x)
{ {
//fprintf(stderr,"canvas_free %lx\n", x);
t_gobj *y; t_gobj *y;
int dspstate = canvas_suspend_dsp(); int dspstate = canvas_suspend_dsp();
if (x->gl_magic_glass) if (x->gl_magic_glass) {
magicGlass_free(x->gl_magic_glass); //magicGlass_free(x->gl_magic_glass);
pd_free(&x->gl_magic_glass->x_obj.te_g.g_pd);
}
//canvas_noundo(x); //canvas_noundo(x);
canvas_undo_free(x); canvas_undo_free(x);
......
...@@ -11,6 +11,7 @@ to this file... */ ...@@ -11,6 +11,7 @@ to this file... */
#include "m_imp.h" #include "m_imp.h"
#include "t_tk.h" #include "t_tk.h"
#include "g_canvas.h" #include "g_canvas.h"
#include "g_all_guis.h" /* for canvas handle freeing */
#include "s_stuff.h" /* for sys_hostfontsize */ #include "s_stuff.h" /* for sys_hostfontsize */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
...@@ -83,8 +84,9 @@ void canvas_closebang(t_canvas *x); ...@@ -83,8 +84,9 @@ void canvas_closebang(t_canvas *x);
/* delete an object from a glist and free it */ /* delete an object from a glist and free it */
void glist_delete(t_glist *x, t_gobj *y) void glist_delete(t_glist *x, t_gobj *y)
{ {
//fprintf(stderr,"glist_delete?\n");
if (x->gl_list) { if (x->gl_list) {
//fprintf(stderr,"glist_delete YES\n");
t_gobj *g; t_gobj *g;
t_object *ob; t_object *ob;
t_gotfn chkdsp = zgetfn(&y->g_pd, gensym("dsp")); t_gotfn chkdsp = zgetfn(&y->g_pd, gensym("dsp"));
...@@ -337,13 +339,23 @@ void glist_sort(t_glist *x) ...@@ -337,13 +339,23 @@ void glist_sort(t_glist *x)
void glist_cleanup(t_glist *x) void glist_cleanup(t_glist *x)
{ {
//fprintf(stderr,"glist_cleanup =============\n");
freebytes(x->gl_xlabel, x->gl_nxlabels * sizeof(*(x->gl_xlabel))); freebytes(x->gl_xlabel, x->gl_nxlabels * sizeof(*(x->gl_xlabel)));
freebytes(x->gl_ylabel, x->gl_nylabels * sizeof(*(x->gl_ylabel))); freebytes(x->gl_ylabel, x->gl_nylabels * sizeof(*(x->gl_ylabel)));
if (x->x_handle) {
pd_unbind(x->x_handle, ((t_scalehandle *)x->x_handle)->h_bindsym);
pd_free(x->x_handle);
}
if (x->x_mhandle) {
pd_unbind(x->x_mhandle, ((t_scalehandle *)x->x_mhandle)->h_bindsym);
pd_free(x->x_mhandle);
}
gstub_cutoff(x->gl_stub); gstub_cutoff(x->gl_stub);
} }
void glist_free(t_glist *x) void glist_free(t_glist *x)
{ {
//fprintf(stderr,"glist_free =============\n");
glist_cleanup(x); glist_cleanup(x);
freebytes(x, sizeof(*x)); freebytes(x, sizeof(*x));
} }
...@@ -1219,6 +1231,7 @@ static void graph_delete(t_gobj *z, t_glist *glist) ...@@ -1219,6 +1231,7 @@ static void graph_delete(t_gobj *z, t_glist *glist)
static void graph_delete(t_gobj *z, t_glist *glist) static void graph_delete(t_gobj *z, t_glist *glist)
{ {
//fprintf(stderr,"graph_delete\n");
t_glist *x = (t_glist *)z; t_glist *x = (t_glist *)z;
t_gobj *y; t_gobj *y;
text_widgetbehavior.w_deletefn(z, glist); text_widgetbehavior.w_deletefn(z, glist);
......
...@@ -398,9 +398,11 @@ void *magicGlass_new(t_glist *c) ...@@ -398,9 +398,11 @@ void *magicGlass_new(t_glist *c)
void magicGlass_free(t_magicGlass *x) void magicGlass_free(t_magicGlass *x)
{ {
//fprintf(stderr,"magicglass_free\n"); //fprintf(stderr,"magicglass_free\n");
magicGlass_unbind(x);
x->x_dspOn = 0; x->x_dspOn = 0;
clock_free(x->x_clearClock); clock_free(x->x_clearClock);
clock_free(x->x_flashClock); clock_free(x->x_flashClock);
x = NULL;
} }
void magicGlass_setup(void) void magicGlass_setup(void)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment