[patch 10/15] [plugins.diff] Minor tweaks to gnc-main-window.c

c.shoemaker at cox.net c.shoemaker at cox.net
Mon Oct 10 10:34:32 EDT 2005


       * src/gnome-utils/gnc-main-window.c:
           - avoid trying to double-add plugins to plugin manager by
             delaying signal connection until the plugins are already
             managed by the plugin manager.
           - question the correctness of a comment

 src/gnome-utils/gnc-main-window.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

Index: gnucash/src/gnome-utils/gnc-main-window.c
===================================================================
--- gnucash.orig/src/gnome-utils/gnc-main-window.c
+++ gnucash/src/gnome-utils/gnc-main-window.c
@@ -306,6 +306,8 @@ gnc_main_window_shutdown (gpointer sessi
  *
  *  @internal
  *
+ * FIXME: I think the comment is wrong.  Aren't all active windows searched?
+ *
  *  @param page The page to search for.
  *
  *  @return TRUE if the page is present in the window, FALSE otherwise.
@@ -507,12 +509,14 @@ gnc_main_window_event_handler (GUID *ent
 	      entity, type, event_type, user_data);
 	window = GNC_MAIN_WINDOW(user_data);
 
+        /* This is not a typical list iteration.  We're removing while
+           we iterate, so we have to be extra careful to check for EOL
+           *before* potentially removing that node. */
 	for (item = window->priv->installed_pages; item; item = next) {
 	  next = g_list_next(item);
 	  page = GNC_PLUGIN_PAGE(item->data);
-	  if (!gnc_plugin_page_has_book (page, entity))
-	    continue;
-	  gnc_main_window_close_page (page);
+	  if (gnc_plugin_page_has_book (page, entity))
+              gnc_main_window_close_page (page);
 	}
 	LEAVE(" ");
 }
@@ -1662,12 +1666,13 @@ gnc_main_window_setup_window (GncMainWin
 	/* GncPluginManager stuff */
 	manager = gnc_plugin_manager_get ();
 	plugins = gnc_plugin_manager_get_plugins (manager);
+        g_list_foreach (plugins, gnc_main_window_add_plugin, window);
+        g_list_free (plugins);
+
 	g_signal_connect (G_OBJECT (manager), "plugin-added",
 			  G_CALLBACK (gnc_main_window_plugin_added), window);
 	g_signal_connect (G_OBJECT (manager), "plugin-removed",
 			  G_CALLBACK (gnc_main_window_plugin_removed), window);
-	g_list_foreach (plugins, gnc_main_window_add_plugin, window);
-	g_list_free (plugins);
 
 }
 

--


More information about the gnucash-devel mailing list