Index: trunk/src/main.c =================================================================== --- trunk/src/main.c (revision 29123) +++ trunk/src/main.c (revision 29124) @@ -285,6 +285,7 @@ gui_support_plugins(0); pcb_render = pcb_gui = NULL; + pcb_tool_uninit_conf(); pcb_hidlib_uninit(); /* plugin unload */ if (PCB != NULL) { Index: trunk/src/tool.c =================================================================== --- trunk/src/tool.c (revision 29123) +++ trunk/src/tool.c (revision 29124) @@ -55,10 +55,11 @@ static conf_hid_id_t tool_conf_id; static const char *pcb_tool_cookie = "default tools"; +static int tool_select_lock = 0; void tool_chg_mode(conf_native_t *cfg, int arr_idx) { - if (PCB != NULL) + if ((PCB != NULL) && (!tool_select_lock)) pcb_tool_select_by_id(&PCB->hidlib, pcbhl_conf.editor.mode); } @@ -81,7 +82,6 @@ void pcb_tool_uninit() { - pcb_conf_hid_unreg(pcb_tool_cookie); default_tool_unreg(); /* temporary */ while(vtp0_len(&pcb_tools) != 0) { const pcb_tool_t *tool = pcb_tool_get(0); @@ -89,9 +89,14 @@ pcb_tool_unreg_by_cookie(tool->cookie); } vtp0_uninit(&pcb_tools); +} +void pcb_tool_uninit_conf(void) +{ + pcb_conf_hid_unreg(pcb_tool_cookie); } + int pcb_tool_reg(pcb_tool_t *tool, const char *cookie) { pcb_toolid_t id; @@ -163,7 +168,9 @@ pcb_tool_next_id = id; uninit_current_tool(); sprintf(id_s, "%d", id); + tool_select_lock = 1; pcb_conf_set(CFR_DESIGN, "editor/mode", -1, id_s, POL_OVERWRITE); + tool_select_lock = 0; init_current_tool(); recursing = pcb_false; Index: trunk/src/tool.h =================================================================== --- trunk/src/tool.h (revision 29123) +++ trunk/src/tool.h (revision 29124) @@ -95,6 +95,7 @@ /* (un)initialize the tool subsystem */ void pcb_tool_init(); void pcb_tool_uninit(); +void pcb_tool_uninit_conf(void); /* call this one before hidlib uninit for conf uninit */ /* Insert a new tool in pcb_tools; returns 0 on success */ int pcb_tool_reg(pcb_tool_t *tool, const char *cookie);