Kaydet (Commit) 5f386751 authored tarafından Jason Cumbie's avatar Jason Cumbie Kaydeden (comit) Colomban Wendling

Do not report incorrect value for GeanyDocument:changed when quitting

Fix document_account_for_unsaved() so it does not alter the `changed`
flag on documents, in order for plugins to have a reliable value there
at all times.

Patch by @chrontec with small additional tidying up.

Closes #1857.
üst 5c428b91
......@@ -704,7 +704,8 @@ static gboolean remove_page(guint page_num)
g_return_val_if_fail(doc != NULL, FALSE);
if (doc->changed && ! dialogs_show_unsaved_file(doc))
/* if we're closing all, document_account_for_unsaved() has been called already, no need to ask again. */
if (! main_status.closing_all && doc->changed && ! dialogs_show_unsaved_file(doc))
return FALSE;
/* tell any plugins that the document is about to be closed */
......@@ -3368,12 +3369,10 @@ GeanyDocument *document_clone(GeanyDocument *old_doc)
}
/* @note If successful, this should always be followed up with a call to
* document_close_all().
* @return TRUE if all files were saved or had their changes discarded. */
/* @return TRUE if all files were saved or had their changes discarded. */
gboolean document_account_for_unsaved(void)
{
guint i, p, page_count;
guint p, page_count;
page_count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook));
/* iterate over documents in tabs order */
......@@ -3387,27 +3386,15 @@ gboolean document_account_for_unsaved(void)
return FALSE;
}
}
/* all documents should now be accounted for, so ignore any changes */
foreach_document (i)
{
documents[i]->changed = FALSE;
}
return TRUE;
}
static void force_close_all(void)
{
guint i, len = documents_array->len;
guint i;
/* check all documents have been accounted for */
for (i = 0; i < len; i++)
{
if (documents[i]->is_valid)
{
g_return_if_fail(!documents[i]->changed);
}
}
main_status.closing_all = TRUE;
foreach_document(i)
......
......@@ -1262,16 +1262,20 @@ static void queue_free(GQueue *queue)
}
static void do_main_quit(void)
static gboolean do_main_quit(void)
{
geany_debug("Quitting...");
configuration_save();
if (app->project != NULL)
project_close(FALSE); /* save project session files */
{
if (!project_close(FALSE)) /* save project session files */
return FALSE;
}
document_close_all();
if (!document_close_all())
return FALSE;
geany_debug("Quitting...");
main_status.quitting = TRUE;
......@@ -1364,6 +1368,8 @@ static void do_main_quit(void)
ui_finalize_builder();
gtk_main_quit();
return TRUE;
}
......@@ -1389,19 +1395,16 @@ gboolean main_quit(void)
if (! check_no_unsaved())
{
if (document_account_for_unsaved())
{
do_main_quit();
if (do_main_quit())
return TRUE;
}
}
else
if (! prefs.confirm_exit ||
dialogs_show_question_full(NULL, GTK_STOCK_QUIT, GTK_STOCK_CANCEL, NULL,
_("Do you really want to quit?")))
{
do_main_quit();
return TRUE;
if (do_main_quit())
return TRUE;
}
main_status.quitting = FALSE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment