Blame SOURCES/0001-gedit-document-fix-close-after-save-functionality.patch

8f91ed
From b0e10edb322665f5a357d9264bfbc4d759b265ea Mon Sep 17 00:00:00 2001
8f91ed
From: Ray Strode <rstrode@redhat.com>
8f91ed
Date: Fri, 15 Apr 2016 13:08:54 -0400
8f91ed
Subject: [PATCH] gedit-document: fix close after save functionality
8f91ed
8f91ed
Right now if a document is modified when a user tries
8f91ed
to close the buffer, we pop up a dialog asking if they
8f91ed
would like to save before closing.  If the user says
8f91ed
yes, we proceed to save the document but then fail to
8f91ed
close it.
8f91ed
8f91ed
This is because we try to close the tab before marking
8f91ed
the now saved document as unmodified. The close operation
8f91ed
then fails.
8f91ed
8f91ed
This commit changes the code to set the document unmodified,
8f91ed
earlier, in time for the close tab operation to succeed.
8f91ed
---
8f91ed
 gedit/gedit-document.c | 4 ++--
8f91ed
 1 file changed, 2 insertions(+), 2 deletions(-)
8f91ed
8f91ed
diff --git a/gedit/gedit-document.c b/gedit/gedit-document.c
8f91ed
index cc59ea1..92c0393 100644
8f91ed
--- a/gedit/gedit-document.c
8f91ed
+++ b/gedit/gedit-document.c
8f91ed
@@ -1187,76 +1187,76 @@ saved_query_info_cb (GFile         *location,
8f91ed
 	if (info != NULL)
8f91ed
 	{
8f91ed
 		if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE))
8f91ed
 		{
8f91ed
 			content_type = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
8f91ed
 		}
8f91ed
 
8f91ed
 		if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED))
8f91ed
 		{
8f91ed
 			g_file_info_get_modification_time (info, &doc->priv->mtime);
8f91ed
 			doc->priv->mtime_set = TRUE;
8f91ed
 		}
8f91ed
 	}
8f91ed
 
8f91ed
 	gedit_document_set_content_type (doc, content_type);
8f91ed
 
8f91ed
 	if (info != NULL)
8f91ed
 	{
8f91ed
 		/* content_type (owned by info) is no longer needed. */
8f91ed
 		g_object_unref (info);
8f91ed
 	}
8f91ed
 
8f91ed
 	g_get_current_time (&doc->priv->time_of_last_save_or_load);
8f91ed
 
8f91ed
 	doc->priv->externally_modified = FALSE;
8f91ed
 	doc->priv->deleted = FALSE;
8f91ed
 	doc->priv->create = FALSE;
8f91ed
 
8f91ed
 	set_readonly (doc, FALSE);
8f91ed
 
8f91ed
-	gtk_text_buffer_set_modified (GTK_TEXT_BUFFER (doc), FALSE);
8f91ed
-
8f91ed
 	save_encoding_metadata (doc);
8f91ed
 
8f91ed
 	/* Async operation finished. */
8f91ed
 	g_object_unref (doc);
8f91ed
 }
8f91ed
 
8f91ed
 static void
8f91ed
 gedit_document_saved_real (GeditDocument *doc)
8f91ed
 {
8f91ed
 	GFile *location = gtk_source_file_get_location (doc->priv->file);
8f91ed
 
8f91ed
 	/* Keep the doc alive during the async operation. */
8f91ed
 	g_object_ref (doc);
8f91ed
 
8f91ed
+	gtk_text_buffer_set_modified (GTK_TEXT_BUFFER (doc), FALSE);
8f91ed
+
8f91ed
 	g_file_query_info_async (location,
8f91ed
 				 G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
8f91ed
 				 G_FILE_ATTRIBUTE_TIME_MODIFIED,
8f91ed
 				 G_FILE_QUERY_INFO_NONE,
8f91ed
 				 G_PRIORITY_DEFAULT,
8f91ed
 				 NULL,
8f91ed
 				 (GAsyncReadyCallback) saved_query_info_cb,
8f91ed
 				 doc);
8f91ed
 }
8f91ed
 
8f91ed
 gboolean
8f91ed
 gedit_document_is_untouched (GeditDocument *doc)
8f91ed
 {
8f91ed
 	GFile *location;
8f91ed
 
8f91ed
 	g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), TRUE);
8f91ed
 
8f91ed
 	location = gtk_source_file_get_location (doc->priv->file);
8f91ed
 
8f91ed
 	return location == NULL && !gtk_text_buffer_get_modified (GTK_TEXT_BUFFER (doc));
8f91ed
 }
8f91ed
 
8f91ed
 gboolean
8f91ed
 gedit_document_is_untitled (GeditDocument *doc)
8f91ed
 {
8f91ed
 	g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), TRUE);
8f91ed
 
8f91ed
 	return gtk_source_file_get_location (doc->priv->file) == NULL;
8f91ed
 }
8f91ed
 
8f91ed
-- 
8f91ed
2.8.1
8f91ed