Index: src/hid/common/hidinit.c =================================================================== --- src/hid/common/hidinit.c (revision 1258) +++ src/hid/common/hidinit.c (revision 1259) @@ -139,6 +139,15 @@ void hid_uninit(void) { hid_actions_uninit(); + + if (hid_num_hids > 0) { + int i; + for (i = hid_num_hids-1; i >= 0; i--) { + if (hid_list[i]->uninit != NULL) + hid_list[i]->uninit(hid_list[i]); + } + } + free(hid_list); } void hid_register_hid(HID * hid) Index: src/hid/lesstif/main.c =================================================================== --- src/hid/lesstif/main.c (revision 1258) +++ src/hid/lesstif/main.c (revision 1259) @@ -1662,6 +1662,7 @@ } extern Widget lesstif_menubar; +static lesstif_hid_inited = 0; static void lesstif_do_export(HID_Attr_Val * options) { @@ -1811,6 +1812,8 @@ lesstif_menubar = menu; event(EVENT_GUI_INIT, NULL); + lesstif_hid_inited = 1; + XtAppMainLoop(app_context); } @@ -1823,7 +1826,10 @@ static void lesstif_uninit(HID *hid) { - lesstif_uninit_menu(); + if (lesstif_hid_inited) { + lesstif_uninit_menu(); + lesstif_hid_inited = 0; + } } Index: src/main.c =================================================================== --- src/main.c (revision 1258) +++ src/main.c (revision 1259) @@ -1570,9 +1570,6 @@ int i; char **s; - if (gui->uninit != NULL) - gui->uninit(gui); - UninitBuffers(); /* Free up memory allocated to the PCB. Why bother when we're about to exit ? @@ -1583,9 +1580,9 @@ free(PCB); PCB = NULL; + hid_uninit(); plugins_uninit(); events_uninit(); - hid_uninit(); for (i = 0; i < MAX_LAYER; i++) free(Settings.DefaultLayerName[i]);