mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Replace fe->preset_menu when we change midend.
Thanks to Rocco Matano for reporting that in the -DCOMBINED version of the Windows front end, switching games causes a crash because the presets menu from the old midend is still left over in fe, and its presence inhibits the setup code from making a new one. Now we throw it out at the same time as we throw out the old midend itself. Also, the condition 'if (!fe->preset_menu)' was misguided. I think the point of that was to avoid pointlessly tearing down and rebuilding the preset menu when we're _not_ changing game - but that's a cost too small to worry about if it causes the slightest trouble. Now fe->preset_menu should always be NULL at that point in the function, so I've replaced the if with an assert.
This commit is contained in:
12
windows.c
12
windows.c
@ -1719,7 +1719,11 @@ static int fe_set_midend(frontend *fe, midend *me)
|
|||||||
int x, y;
|
int x, y;
|
||||||
RECT r;
|
RECT r;
|
||||||
|
|
||||||
if (fe->me) midend_free(fe->me);
|
if (fe->me) {
|
||||||
|
midend_free(fe->me);
|
||||||
|
fe->preset_menu = NULL;
|
||||||
|
sfree(fe->preset_menuitems);
|
||||||
|
}
|
||||||
fe->me = me;
|
fe->me = me;
|
||||||
fe->game = midend_which_game(fe->me);
|
fe->game = midend_which_game(fe->me);
|
||||||
|
|
||||||
@ -1847,12 +1851,14 @@ static int fe_set_midend(frontend *fe, midend *me)
|
|||||||
AppendMenu(menu, MF_ENABLED, IDM_SEED, TEXT("Rando&m Seed..."));
|
AppendMenu(menu, MF_ENABLED, IDM_SEED, TEXT("Rando&m Seed..."));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!fe->preset_menu) {
|
assert(!fe->preset_menu);
|
||||||
int i;
|
|
||||||
fe->preset_menu = midend_get_presets(
|
fe->preset_menu = midend_get_presets(
|
||||||
fe->me, &fe->n_preset_menuitems);
|
fe->me, &fe->n_preset_menuitems);
|
||||||
fe->preset_menuitems = snewn(fe->n_preset_menuitems,
|
fe->preset_menuitems = snewn(fe->n_preset_menuitems,
|
||||||
struct preset_menuitemref);
|
struct preset_menuitemref);
|
||||||
|
{
|
||||||
|
int i;
|
||||||
for (i = 0; i < fe->n_preset_menuitems; i++)
|
for (i = 0; i < fe->n_preset_menuitems; i++)
|
||||||
fe->preset_menuitems[i].which_menu = NULL;
|
fe->preset_menuitems[i].which_menu = NULL;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user