Commit 65647f90 authored by Albert Gräf's avatar Albert Gräf
Browse files

Fix up the dummy canvas environment in abstracthandler_callback.

Instead of casting a magic number to a pointer, which is a sure recipe
for disaster, provide a properly initialized dummy t_canvasenvironment*
pointing to static storage.
parent edb80827
......@@ -43,6 +43,19 @@ struct _canvasenvironment
t_namelist *ce_path; /* search path */
};
t_canvasenvironment *dummy_canvas_env(const char *dir)
{
static t_canvasenvironment dummy_env = {
.ce_dir = NULL,
.ce_argc = 0,
.ce_argv = NULL,
.ce_dollarzero = 0,
.ce_path = NULL
};
dummy_env.ce_dir = gensym(dir);
return &dummy_env;
}
#define GLIST_DEFCANVASWIDTH 450
#define GLIST_DEFCANVASHEIGHT 300
......
......@@ -76,6 +76,8 @@ EXTERN_STRUCT _tscalar;
EXTERN_STRUCT _canvasenvironment;
#define t_canvasenvironment struct _canvasenvironment
extern t_canvasenvironment *dummy_canvas_env(const char *dir);
EXTERN_STRUCT _fielddesc;
#define t_fielddesc struct _fielddesc
......
......@@ -2360,7 +2360,7 @@ static void abstracthandler_callback(t_abstracthandler *x, t_symbol *s)
/* save the subpatch into a separated pd file */
t_atom at[3];
SETSYMBOL(at, gensym(filename)); SETSYMBOL(at+1, gensym(dir)); SETFLOAT(at+2, 0.f);
x->tarjet->gl_env = 0xF1A6; /* gl_env is set to non-zero in order to save the subcanvas as a root canvas */
x->tarjet->gl_env = dummy_canvas_env(dir); /* gl_env is set to non-zero in order to save the subcanvas as a root canvas */
typedmess(&x->tarjet->gl_pd, gensym("savetofile"), 3, at);
x->tarjet->gl_env = 0;
......
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