SF.net SVN: geany:[5738] trunk

colombanw at users.sourceforge.net colombanw at xxxxx
Tue Apr 26 13:52:31 UTC 2011


Revision: 5738
          http://geany.svn.sourceforge.net/geany/?rev=5738&view=rev
Author:   colombanw
Date:     2011-04-26 13:52:31 +0000 (Tue, 26 Apr 2011)

Log Message:
-----------
Make sure to update the tag list only for the current document

Fix idle tag list updating not to update the tag list if the current
document isn't the one to update anymore. In this case, mark the
document as needing an update and re-schedule an idle update next time
the document gets the focus.

This fixes updating the tag list after switching documents, which
resulted in displaying the wrong tag list.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/callbacks.c
    trunk/src/document.c
    trunk/src/document.h
    trunk/src/documentprivate.h
    trunk/src/editor.c
    trunk/src/sidebar.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2011-04-25 16:23:58 UTC (rev 5737)
+++ trunk/ChangeLog	2011-04-26 13:52:31 UTC (rev 5738)
@@ -1,3 +1,11 @@
+2011-04-26  Colomban Wendling  <colomban(at)geany(dot)org>
+
+ * src/callbacks.c, src/document.c, src/document.h,
+   src/documentprivate.h, src/editor.c, src/sidebar.c:
+   Make sure to update the tag list only for the current document,
+   avoiding idle updates to show the tag list for the wrong document.
+
+
 2011-04-25  Nick Treleaven  <nick(dot)treleaven(at)btinternet(dot)com>
 
  * src/utils.c:

Modified: trunk/src/callbacks.c
===================================================================
--- trunk/src/callbacks.c	2011-04-25 16:23:58 UTC (rev 5737)
+++ trunk/src/callbacks.c	2011-04-26 13:52:31 UTC (rev 5738)
@@ -709,6 +709,8 @@
 		ui_update_popup_reundo_items(doc);
 		ui_document_show_hide(doc); /* update the document menu */
 		build_menu_update(doc);
+		if (doc->priv->tag_list_update_needed)
+			document_update_tag_list_in_idle(doc);
 		sidebar_update_tag_list(doc, FALSE);
 
 		/* We delay the check to avoid weird fast, unintended switching of notebook pages when

Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c	2011-04-25 16:23:58 UTC (rev 5737)
+++ trunk/src/document.c	2011-04-26 13:52:31 UTC (rev 5738)
@@ -395,6 +395,8 @@
 	priv->undo_actions = NULL;
 	priv->redo_actions = NULL;
 	priv->line_count = 0;
+	priv->tag_list_update_source = 0;
+	priv->tag_list_update_needed = FALSE;
 #if ! defined(USE_GIO_FILEMON)
 	priv->last_check = time(NULL);
 #endif
@@ -2324,6 +2326,38 @@
 }
 
 
+static gboolean on_document_update_tag_list_idle(gpointer data)
+{
+	GeanyDocument *doc = data;
+
+	if (! DOC_VALID(doc))
+		return FALSE;
+
+	if (! main_status.quitting)
+	{
+		if (doc == document_get_current ())
+			document_update_tag_list(doc, TRUE);
+		else
+			doc->priv->tag_list_update_needed = TRUE;
+	}
+
+	doc->priv->tag_list_update_source = 0;
+	return FALSE;
+}
+
+
+void document_update_tag_list_in_idle(GeanyDocument *doc)
+{
+	if (editor_prefs.autocompletion_update_freq <= 0 || ! filetype_has_tags(doc->file_type))
+		return;
+
+	if (doc->priv->tag_list_update_source != 0)
+		g_source_remove(doc->priv->tag_list_update_source);
+	doc->priv->tag_list_update_source = g_timeout_add_full(G_PRIORITY_LOW,
+		editor_prefs.autocompletion_update_freq, on_document_update_tag_list_idle, doc, NULL);
+}
+
+
 /* Caches the list of project typenames, as a space separated GString.
  * Returns: TRUE if typenames have changed.
  * (*types) is set to the list of typenames, or NULL if there are none. */

Modified: trunk/src/document.h
===================================================================
--- trunk/src/document.h	2011-04-25 16:23:58 UTC (rev 5737)
+++ trunk/src/document.h	2011-04-26 13:52:31 UTC (rev 5738)
@@ -231,6 +231,8 @@
 
 void document_update_tag_list(GeanyDocument *doc, gboolean update);
 
+void document_update_tag_list_in_idle(GeanyDocument *doc);
+
 void document_set_encoding(GeanyDocument *doc, const gchar *new_encoding);
 
 gboolean document_check_disk_status(GeanyDocument *doc, gboolean force);

Modified: trunk/src/documentprivate.h
===================================================================
--- trunk/src/documentprivate.h	2011-04-25 16:23:58 UTC (rev 5737)
+++ trunk/src/documentprivate.h	2011-04-26 13:52:31 UTC (rev 5738)
@@ -84,6 +84,10 @@
 	time_t			 last_check;
 	/* Modification time of the document on disk, only used when legacy file monitoring is used. */
 	time_t			 mtime;
+	/* ID of the idle callback updating the tag list */
+	guint			 tag_list_update_source;
+	/* whether there is a tag list update we haven't had a chance to honor yet */
+	gboolean		 tag_list_update_needed;
 }
 GeanyDocumentPrivate;
 

Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c	2011-04-25 16:23:58 UTC (rev 5737)
+++ trunk/src/editor.c	2011-04-26 13:52:31 UTC (rev 5738)
@@ -85,9 +85,6 @@
 /* holds word under the mouse or keyboard cursor */
 static gchar current_word[GEANY_MAX_WORD_LENGTH];
 
-/* whether there is a tag list update pending */
-static guint document_tags_update_source = 0;
-
 /* Initialised in keyfile.c. */
 GeanyEditorPrefs editor_prefs;
 
@@ -1001,27 +998,6 @@
 }
 
 
-static gboolean on_document_update_tags_idle(gpointer data)
-{
-	GeanyDocument *doc = data;
-
-	if (!main_status.quitting && DOC_VALID(doc))
-		document_update_tag_list(doc, TRUE);
-
-	document_tags_update_source = 0;
-	return FALSE;
-}
-
-
-static void request_tag_list_update(GeanyDocument *doc)
-{
-	if (document_tags_update_source)
-		g_source_remove(document_tags_update_source);
-	document_tags_update_source = g_timeout_add_full(G_PRIORITY_LOW,
-		editor_prefs.autocompletion_update_freq, on_document_update_tags_idle, doc, NULL);
-}
-
-
 static gboolean on_editor_notify(G_GNUC_UNUSED GObject *object, GeanyEditor *editor,
 								 SCNotification *nt, G_GNUC_UNUSED gpointer data)
 {
@@ -1083,11 +1059,9 @@
 				/* handle special fold cases, e.g. #1923350 */
 				fold_changed(sci, nt->line, nt->foldLevelNow, nt->foldLevelPrev);
 			}
-			if (editor_prefs.autocompletion_update_freq > 0 &&
-				(nt->modificationType & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT)) &&
-				filetype_has_tags(doc->file_type))
+			if (nt->modificationType & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT))
 			{
-				request_tag_list_update(doc);
+				document_update_tag_list_in_idle(doc);
 			}
 			break;
 

Modified: trunk/src/sidebar.c
===================================================================
--- trunk/src/sidebar.c	2011-04-25 16:23:58 UTC (rev 5737)
+++ trunk/src/sidebar.c	2011-04-26 13:52:31 UTC (rev 5738)
@@ -213,6 +213,8 @@
 		return;
 	}
 
+	doc->priv->tag_list_update_needed = FALSE;
+
 	if (update)
 	{	/* updating the tag list in the left tag window */
 		if (doc->priv->tag_tree == NULL)


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