Commit dec3b6c0 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

fix #116: segfault after applying preferences change

parent e3142f04
......@@ -71,16 +71,16 @@ static void glob_perf(t_pd *dummy, float f)
sys_perf = (f != 0);
}
extern char *sys_gui_preset;
extern t_symbol *sys_gui_preset;
static void glob_gui_preset(t_pd *dummy, t_symbol *s)
{
sys_gui_preset = s->s_name;
sys_gui_preset = s;
}
/* just the gui-preset for now */
static void glob_gui_properties(t_pd *dummy)
{
gui_vmess("gui_gui_properties", "xs", 0, sys_gui_preset);
gui_vmess("gui_gui_properties", "xs", 0, sys_gui_preset->s_name);
}
// ths one lives inside g_editor so that it can access the clipboard
......
......@@ -212,7 +212,8 @@ static void sys_putpreference(const char *key, const char *value)
NULL, &hkey, NULL);
if (err != ERROR_SUCCESS)
{
post("unable to create registry entry: %s\n", key);
post("unable to create registry entry: %s: error %lx\n", key,
(long unsigned int)err);
return;
}
err = RegSetValueEx(hkey, key, 0, REG_EXPAND_SZ, value, strlen(value)+1);
......@@ -438,7 +439,11 @@ void sys_loadpreferences( void)
if (sys_getpreference("defeatrt", prefbuf, MAXPDSTRING))
sscanf(prefbuf, "%d", &sys_defeatrt);
if (sys_getpreference("guipreset", prefbuf, MAXPDSTRING))
sscanf(prefbuf, "%s", &sys_gui_preset);
{
char preset_buf[MAXPDSTRING];
sscanf(prefbuf, "%s", preset_buf);
sys_gui_preset = gensym(preset_buf);
}
if (sys_getpreference("flags", prefbuf, MAXPDSTRING))
{
if (strcmp(prefbuf, "."))
......@@ -553,7 +558,7 @@ void glob_savepreferences(t_pd *dummy)
sys_putpreference("nloadlib", buf1);
sprintf(buf1, "%d", sys_defeatrt);
sys_putpreference("defeatrt", buf1);
sys_putpreference("guipreset", sys_gui_preset);
sys_putpreference("guipreset", sys_gui_preset->s_name);
sys_putpreference("flags",
(sys_flags ? sys_flags->s_name : ""));
sys_donesavepreferences();
......
......@@ -55,7 +55,7 @@ int sys_unique = 0; /* by default off, prevents multiple instances
int sys_legacy = 0; /* by default off, used to enable legacy features,
such as offsets in iemgui object positioning */
char *sys_guicmd;
char *sys_gui_preset = "default"; /* name of the gui theme to be used */
t_symbol *sys_gui_preset; /* name of gui theme to be used */
t_symbol *sys_libdir;
t_symbol *sys_guidir;
static t_namelist *sys_openlist;
......@@ -264,6 +264,7 @@ int sys_main(int argc, char **argv)
int i, noprefs;
sys_externalschedlib = 0;
sys_extraflags = 0;
sys_gui_preset = gensym("default");
#ifdef PD_DEBUG
fprintf(stderr, "Pd-L2Ork: COMPILED FOR DEBUGGING\n");
#endif
......@@ -292,7 +293,8 @@ int sys_main(int argc, char **argv)
/* send the libdir to the GUI */
gui_vmess("gui_set_lib_dir", "s", sys_libdir->s_name);
/* send the name of the gui preset */
gui_vmess("gui_set_gui_preset", "s", sys_gui_preset);
gui_vmess("gui_set_gui_preset", "s", sys_gui_preset->s_name);
if (sys_openlist)
{
// send the files to be opened to the GUI. We send them one
......
......@@ -39,7 +39,7 @@ t_symbol *sys_decodedialog(t_symbol *s);
void sys_loadpreferences( void);
void sys_savepreferences( void);
extern int sys_defeatrt;
extern char *sys_gui_preset;
extern t_symbol *sys_gui_preset;
extern t_symbol *sys_flags;
/* s_main.c */
......
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