Commit 5b97882a authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

removed rendundant memory hack and found potentially real and permanent fix to...

removed rendundant memory hack and found potentially real and permanent fix to the double-entry bug (see g_canvas.c inside canvas_free() function). Many thanks to Krzysztof Czaja for his incredibly helpful hint!
parent 731fac3a
......@@ -344,7 +344,7 @@ void glist_init(t_glist *x)
}
/* global var used by pd_new() to work with redundant memory, originally defined in m_pd.c */
extern int canvas_check_duplicate;
//extern int canvas_check_duplicate;
/* make a new glist. It will either be a "root" canvas or else
it appears as a "text" object in another window (canvas_getcurrent()
......@@ -357,6 +357,7 @@ t_canvas *canvas_new(void *dummy, t_symbol *sel, int argc, t_atom *argv)
//if (x->gl_owner && x->gl_env) {
/*
t_redundant_mem *new_rm = (t_redundant_mem *)t_getbytes(sizeof(*new_rm));
//new_rm->rm_what = (int)getbytes(1);
if (rm_start == NULL) {
......@@ -376,9 +377,10 @@ t_canvas *canvas_new(void *dummy, t_symbol *sel, int argc, t_atom *argv)
}
//}
canvas_check_duplicate = -1;
canvas_check_duplicate = -1;*/
t_canvas *x = (t_canvas *)pd_new(canvas_class);
rm_end->rm_canvas = x;
//rm_end->rm_canvas = x;
t_canvas *owner = canvas_getcurrent();
t_symbol *s = &s_;
int vis = 0, width = GLIST_DEFCANVASWIDTH, height = GLIST_DEFCANVASHEIGHT;
......@@ -919,6 +921,9 @@ void canvas_free(t_canvas *x)
if (x == glist_getcanvas(x))
canvas_vis(x, 0);
if (x->gl_editor)
canvas_destroy_editor(x);
if (strcmp(x->gl_name->s_name, "Pd")) {
//fprintf(stderr,"canvas_free calling pd_unbind\n");
pd_unbind(&x->gl_pd, canvas_makebindsym(x->gl_name));
......
......@@ -45,8 +45,7 @@ extern "C" {
instantiated inside canvas_new since the bug only affects new
canvases/abstractions rather than individual objects. the queue
is destructed in m_glob.c quit call (when pd exits) */
/*
typedef struct _redundant_mem
{
//int rm_what;
......@@ -56,7 +55,7 @@ typedef struct _redundant_mem
t_redundant_mem *rm_start;
t_redundant_mem *rm_end;
*/
/* --------------------- geometry ---------------------------- */
#define IOWIDTH 7 /* width of an inlet/outlet in pixels */
......
......@@ -11,10 +11,11 @@
/* FIXME no out-of-memory testing yet! */
int canvas_check_duplicate = 0;
/*int canvas_check_duplicate = 0;
extern t_redundant_mem *rm_start;
extern t_redundant_mem *rm_end;
*/
t_pd *pd_new(t_class *c)
{
......@@ -45,7 +46,7 @@ t_pd *pd_new(t_class *c)
//int random_extra = 0;
//int random_offset = 1;
/*
while (canvas_check_duplicate != 0) {
if (canvas_check_duplicate == -1) {
......@@ -78,21 +79,22 @@ t_pd *pd_new(t_class *c)
}
//fprintf(stderr,"done alloc %d\n", canvas_check_duplicate);
/*if (canvas_check_duplicate == 1) {
//fprintf(stderr,"duplicate\n");
if (!random_extra)
t_freebytes(x, sizeof(c->c_size));
else
t_freebytes(x, sizeof(c->c_size+random_extra));
}
if (!canvas_check_duplicate && random_extra) {
x = (t_pd *)t_resizebytes(x, c->c_size+random_extra, c->c_size);
break;
}*/
//if (canvas_check_duplicate == 1) {
// //fprintf(stderr,"duplicate\n");
// if (!random_extra)
// t_freebytes(x, sizeof(c->c_size));
// else
// t_freebytes(x, sizeof(c->c_size+random_extra));
//}
//
//if (!canvas_check_duplicate && random_extra) {
// x = (t_pd *)t_resizebytes(x, c->c_size+random_extra, c->c_size);
// break;
//}
}
if (!x) x = (t_pd *)t_getbytes(c->c_size);
if (!x) x = (t_pd *)t_getbytes(c->c_size);*/
x = (t_pd *)t_getbytes(c->c_size);
*x = c;
if (c->c_patchable)
{
......
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