better WM_DELETE_WINDOW protocol handler in case of multiple windows

This commit is contained in:
Stefan Frederik 2022-01-14 19:37:01 +01:00
parent 231660989a
commit 158186a9c4
3 changed files with 13 additions and 8 deletions

View File

@ -338,7 +338,7 @@ void merge_file(int selection_load, const char ext[])
if(selection_load==0)
{
if(!strcmp(ext,"")) {
my_snprintf(tmp, S(tmp), "load_file_dialog {Merge file} {.sch.sym} INITIALLOADDIR", ext);
my_snprintf(tmp, S(tmp), "load_file_dialog {Merge file} {.sch.sym} INITIALLOADDIR");
tcleval(tmp);
if(!strcmp(tclresult(),"")) return;
my_strncpy(name, (char *)tclresult(), S(name));

View File

@ -1213,7 +1213,7 @@ static void destroy_window(int *window_count, const char *win_path)
savectx = xctx;
if(*window_count) {
int close = 0;
dbg(1, "new_schematic() destroy {%s}\n", win_path);
dbg(0, "new_schematic() destroy {%s}\n", win_path);
if(xctx->modified && has_x) {
tcleval("tk_messageBox -type okcancel -parent [xschem get topwindow] -message \""
"[get_cell [xschem get schname] 0]"

View File

@ -4607,14 +4607,19 @@ proc build_widgets { {topwin {} } } {
#wm maxsize . 1600 1200
if { $rootwin == {.}} {
wm protocol $rootwin WM_DELETE_WINDOW {
if { [xschem get current_win_path] eq {.drw} } {
xschem exit
} else {
xschem new_schematic destroy [xschem get current_win_path] {}
}
set old [xschem get current_win_path]
save_ctx $old
restore_ctx .drw
housekeeping_ctx
xschem new_schematic switch_win .drw
xschem exit
# did not exit ... switch back
restore_ctx $old
housekeeping_ctx
xschem new_schematic switch_win $old
}
} else {
wm protocol $topwin WM_DELETE_WINDOW "xschem new_schematic destroy $topwin.drw {}"
wm protocol $rootwin WM_DELETE_WINDOW "xschem new_schematic destroy $topwin.drw {}"
}
frame $topwin.statusbar