SF.net SVN: geany:[3868] trunk

ntrel at users.sourceforge.net ntrel at xxxxx
Wed Jun 17 10:46:43 UTC 2009


Revision: 3868
          http://geany.svn.sourceforge.net/geany/?rev=3868&view=rev
Author:   ntrel
Date:     2009-06-17 10:46:43 +0000 (Wed, 17 Jun 2009)

Log Message:
-----------
Make GeanyDocument::file_type always be non-NULL, even for a new
document with no filetype set.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/document.c
    trunk/src/document.h
    trunk/src/filetypes.h
    trunk/src/ui_utils.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2009-06-16 21:25:04 UTC (rev 3867)
+++ trunk/ChangeLog	2009-06-17 10:46:43 UTC (rev 3868)
@@ -1,3 +1,10 @@
+2009-06-17  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>
+
+ * src/filetypes.h, src/document.c, src/document.h, src/ui_utils.c:
+   Make GeanyDocument::file_type always be non-NULL, even for a new
+   document with no filetype set.
+
+
 2009-06-16  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>
 
  * src/dialogs.c:

Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c	2009-06-16 21:25:04 UTC (rev 3867)
+++ trunk/src/document.c	2009-06-17 10:46:43 UTC (rev 3868)
@@ -766,13 +766,11 @@
 	/* store the opened encoding for undo/redo */
 	store_saved_encoding(doc);
 
-	/*document_set_filetype(idx, (ft == NULL) ? filetypes[GEANY_FILETYPES_NONE] : ft);*/
 	if (ft == NULL && utf8_filename != NULL) /* guess the filetype from the filename if one is given */
 		ft = filetypes_detect_from_document(doc);
 
 	document_set_filetype(doc, ft);	/* also clears taglist */
-	if (ft == NULL)
-		highlighting_set_styles(doc->editor->sci, GEANY_FILETYPES_NONE);
+
 	ui_set_window_title(doc);
 	build_menu_update(doc);
 	document_update_tag_list(doc, FALSE);
@@ -2469,8 +2467,9 @@
 {
 	gboolean ft_changed;
 
-	if (type == NULL || doc == NULL)
-		return;
+	g_return_if_fail(doc);
+	if (type == NULL)
+		type = filetypes[GEANY_FILETYPES_NONE];
 
 	geany_debug("%s : %s (%s)",
 		(doc->file_name != NULL) ? doc->file_name : "unknown",

Modified: trunk/src/document.h
===================================================================
--- trunk/src/document.h	2009-06-16 21:25:04 UTC (rev 3867)
+++ trunk/src/document.h	2009-06-17 10:46:43 UTC (rev 3868)
@@ -88,7 +88,7 @@
 	/** The filetype for this %document, it's only a reference to one of the elements of the global
 	 *  filetypes array. */
 	GeanyFiletype	*file_type;
-	/** TMWorkObject object for this %document. */
+	/** TMWorkObject object for this %document, or @c NULL. */
 	TMWorkObject	*tm_file;
 	/** Whether this %document is read-only. */
 	gboolean		 readonly;

Modified: trunk/src/filetypes.h
===================================================================
--- trunk/src/filetypes.h	2009-06-16 21:25:04 UTC (rev 3867)
+++ trunk/src/filetypes.h	2009-06-17 10:46:43 UTC (rev 3868)
@@ -94,7 +94,8 @@
 GeanyFiletypeGroupID;
 
 
-/* Safe wrapper to get the id field of a possibly NULL filetype pointer. */
+/* Safe wrapper to get the id field of a possibly NULL filetype pointer.
+ * This shouldn't be necessary since GeanyDocument::file_type is always non-NULL. */
 #define FILETYPE_ID(filetype_ptr) \
 	(((filetype_ptr) != NULL) ? (filetype_ptr)->id : GEANY_FILETYPES_NONE)
 

Modified: trunk/src/ui_utils.c
===================================================================
--- trunk/src/ui_utils.c	2009-06-16 21:25:04 UTC (rev 3867)
+++ trunk/src/ui_utils.c	2009-06-17 10:46:43 UTC (rev 3868)
@@ -150,14 +150,6 @@
 }
 
 
-static GeanyFiletype *document_get_filetype(GeanyDocument *doc)
-{
-	g_return_val_if_fail(doc, NULL);
-
-	return filetypes[FILETYPE_ID(doc->file_type)];
-}
-
-
 /* updates the status bar document statistics */
 void ui_update_statusbar(GeanyDocument *doc, gint pos)
 {
@@ -173,7 +165,7 @@
 		const gchar sp[] = "      ";
 		guint line, col;
 		const gchar *cur_tag;
-		gchar *filetype_name = document_get_filetype(doc)->name;
+		gchar *filetype_name = doc->file_type->name;
 
 		if (G_UNLIKELY(stats_str == NULL))
 			stats_str = g_string_sized_new(120);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list