From a2a63aa8c10b276fc77f351c77a09e1e75dc476f Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Sat, 10 Feb 2018 18:16:51 +0300 Subject: [PATCH] Ticket #3898: mcedit doesn't save all opened files. (edit_quit): do not call widget_select() while direct iterating editor windows because it changes the window position in Z order. Collect modified files in separate list. Signed-off-by: Andrew Borodin --- src/editor/editwidget.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/editor/editwidget.c b/src/editor/editwidget.c index a6b02b16f..be37612b9 100644 --- a/src/editor/editwidget.c +++ b/src/editor/editwidget.c @@ -632,10 +632,13 @@ edit_quit (WDialog * h) { GList *l; WEdit *e = NULL; + GSList *m = NULL; + GSList *me; /* don't stop the dialog before final decision */ widget_set_state (WIDGET (h), WST_ACTIVE, TRUE); + /* check window state and get modified files */ for (l = h->widgets; l != NULL; l = g_list_next (l)) if (edit_widget_is_editor (CONST_WIDGET (l->data))) { @@ -644,21 +647,31 @@ edit_quit (WDialog * h) if (e->drag_state != MCEDIT_DRAG_NONE) { edit_restore_size (e); + g_slist_free (m); return; } + /* create separate list because widget_select() + changes the window position in Z order */ if (e->modified) - { - widget_select (WIDGET (e)); - - if (!edit_ok_to_exit (e)) - return; - } + m = g_slist_prepend (m, l->data); } - /* no editors in dialog at all or no any file required to be saved */ - if (e == NULL || l == NULL) + for (me = m; me != NULL; me = g_slist_next (me)) + { + e = (WEdit *) me->data; + + widget_select (WIDGET (e)); + + if (!edit_ok_to_exit (e)) + break; + } + + /* if all files were checked, quit editor */ + if (me == NULL) dlg_stop (h); + + g_slist_free (m); } /* --------------------------------------------------------------------------------------------- */