[gedit/wip/loader-saver: 36/48] GeditDocument: fix bug with content type
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit/wip/loader-saver: 36/48] GeditDocument: fix bug with content type
- Date: Wed, 9 Jul 2014 11:11:03 +0000 (UTC)
commit 8b6976cf225d44d928b7ff6cd2f26d81d665a5de
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Jun 28 21:38:56 2014 +0200
GeditDocument: fix bug with content type
gedit/gedit-document.c | 32 ++++++++++++++++++++------------
1 files changed, 20 insertions(+), 12 deletions(-)
---
diff --git a/gedit/gedit-document.c b/gedit/gedit-document.c
index 957ed38..1b2ce96 100644
--- a/gedit/gedit-document.c
+++ b/gedit/gedit-document.c
@@ -1045,7 +1045,6 @@ loaded_query_info_cb (GFile *location,
GFileInfo *info;
const gchar *content_type = NULL;
gboolean read_only = FALSE;
- GTimeVal mtime = {0, 0};
GError *error = NULL;
info = g_file_query_info_finish (location, result, &error);
@@ -1057,6 +1056,8 @@ loaded_query_info_cb (GFile *location,
error = NULL;
}
+ doc->priv->mtime_set = FALSE;
+
if (info != NULL)
{
if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE))
@@ -1071,16 +1072,13 @@ loaded_query_info_cb (GFile *location,
if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED))
{
- g_file_info_get_modification_time (info, &mtime);
+ g_file_info_get_modification_time (info, &doc->priv->mtime);
+ doc->priv->mtime_set = TRUE;
}
-
- g_object_unref (info);
}
set_readonly (doc, read_only);
- doc->priv->mtime = mtime;
- doc->priv->mtime_set = TRUE;
g_get_current_time (&doc->priv->time_of_last_save_or_load);
doc->priv->externally_modified = FALSE;
@@ -1088,6 +1086,12 @@ loaded_query_info_cb (GFile *location,
gedit_document_set_content_type (doc, content_type);
+ if (info != NULL)
+ {
+ /* content_type (owned by info) is no longer needed. */
+ g_object_unref (info);
+ }
+
if (!doc->priv->language_set_by_user)
{
GtkSourceLanguage *language = guess_language (doc);
@@ -1128,7 +1132,6 @@ saved_query_info_cb (GFile *location,
{
GFileInfo *info;
const gchar *content_type = NULL;
- GTimeVal mtime = {0, 0};
GError *error = NULL;
info = g_file_query_info_finish (location, result, &error);
@@ -1140,6 +1143,8 @@ saved_query_info_cb (GFile *location,
error = NULL;
}
+ doc->priv->mtime_set = FALSE;
+
if (info != NULL)
{
if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE))
@@ -1149,16 +1154,19 @@ saved_query_info_cb (GFile *location,
if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED))
{
- g_file_info_get_modification_time (info, &mtime);
+ g_file_info_get_modification_time (info, &doc->priv->mtime);
+ doc->priv->mtime_set = TRUE;
}
-
- g_object_unref (info);
}
gedit_document_set_content_type (doc, content_type);
- doc->priv->mtime = mtime;
- doc->priv->mtime_set = TRUE;
+ if (info != NULL)
+ {
+ /* content_type (owned by info) is no longer needed. */
+ g_object_unref (info);
+ }
+
g_get_current_time (&doc->priv->time_of_last_save_or_load);
doc->priv->externally_modified = FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]