r14753 - gnucash/branches/2.0 - Remove overloading of an argument passed to the

Derek Atkins warlord at cvs.gnucash.org
Mon Aug 28 23:26:42 EDT 2006


Author: warlord
Date: 2006-08-28 23:26:36 -0400 (Mon, 28 Aug 2006)
New Revision: 14753
Trac: http://svn.gnucash.org/trac/changeset/14753

Modified:
   gnucash/branches/2.0/
   gnucash/branches/2.0/ChangeLog
   gnucash/branches/2.0/src/core-utils/gnc-gconf-utils.c
   gnucash/branches/2.0/src/core-utils/gnc-gconf-utils.h
   gnucash/branches/2.0/src/gnome-utils/dialog-preferences.c
   gnucash/branches/2.0/src/gnome-utils/dialog-reset-warnings.c
   gnucash/branches/2.0/src/gnome-utils/gnc-main-window.c
   gnucash/branches/2.0/src/gnome-utils/gnc-plugin.c
   gnucash/branches/2.0/src/gnome-utils/gnc-plugin.h
   gnucash/branches/2.0/src/gnome-utils/gnc-tree-view.c
Log:
Remove overloading of an argument passed to the
gnc_gconf_add/remove_notification functions..  This will solve a crash
on Solaris caused by g_vasprintf being passed a "%s" format string and
a NULL as argument.

Merge from r14675.




Property changes on: gnucash/branches/2.0
___________________________________________________________________
Name: svk:merge
   - d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/2.0:13054
   + d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/2.0:13181

Modified: gnucash/branches/2.0/ChangeLog
===================================================================
--- gnucash/branches/2.0/ChangeLog	2006-08-28 19:28:47 UTC (rev 14752)
+++ gnucash/branches/2.0/ChangeLog	2006-08-29 03:26:36 UTC (rev 14753)
@@ -5,6 +5,19 @@
 
 	* src/engine/Account.c: Add missing call to xaccAccountBeginEdit.
 
+2006-08-15  David Hampton  <hampton at employees.org>
+
+	* src/core-utils/gnc-gconf-utils.[ch]:
+	* src/gnome-utils/dialog-preferences.c:
+	* src/gnome-utils/gnc-plugin.[ch]:
+	* src/gnome-utils/gnc-main-window.c:
+	* src/gnome-utils/dialog-reset-warnings.c:
+	* src/gnome-utils/gnc-tree-view.c: Remove overloading of an
+	argument passed to the gnc_gconf_add/remove_notification
+	functions..  This will solve a crash on Solaris caused by
+	g_vasprintf being passed a "%s" format string and a NULL as
+	argument.
+
 2006-08-14  David Hampton  <hampton at employees.org>
 
 	* doc/tip_of_the_day.list.in: Add a tip for raising the accounts

Modified: gnucash/branches/2.0/src/core-utils/gnc-gconf-utils.c
===================================================================
--- gnucash/branches/2.0/src/core-utils/gnc-gconf-utils.c	2006-08-28 19:28:47 UTC (rev 14752)
+++ gnucash/branches/2.0/src/core-utils/gnc-gconf-utils.c	2006-08-29 03:26:36 UTC (rev 14753)
@@ -743,7 +743,8 @@
 void
 gnc_gconf_add_notification (GObject *object,
 			    const gchar *section,
-			    GConfClientNotifyFunc callback)
+			    GConfClientNotifyFunc callback,
+			    const gchar *whoami)
 {
 	GConfClient *client;
 	GError *error = NULL;
@@ -752,6 +753,7 @@
 
 	g_return_if_fail(G_IS_OBJECT(object));
 	g_return_if_fail(callback != NULL);
+	g_return_if_fail(whoami != NULL);
 
 	client = gconf_client_get_default();
 	path = gnc_gconf_section_name(section);
@@ -785,8 +787,8 @@
 	/*
 	 * Save the values needed to undo this later.
 	 */
-	client_tag = g_strdup_printf(CLIENT_TAG, section);
-	notify_tag = g_strdup_printf(NOTIFY_TAG, section);
+	client_tag = g_strdup_printf(CLIENT_TAG, whoami);
+	notify_tag = g_strdup_printf(NOTIFY_TAG, whoami);
 	g_object_set_data(object, client_tag, client);
 	g_object_set_data(object, notify_tag, GUINT_TO_POINTER(id));
 	g_free(notify_tag);
@@ -843,22 +845,24 @@
 
 void
 gnc_gconf_remove_notification (GObject *object,
-			       const gchar *section)
+			       const gchar *section,
+			       const gchar *whoami)
 {
 	GConfClient *client;
 	gchar *path, *client_tag, *notify_tag;
 	guint id;
 
 	g_return_if_fail(G_IS_OBJECT(object));
+	g_return_if_fail(whoami != NULL);
 
 	/*
 	 * Remove any gconf notifications
 	 */
-	client_tag = g_strdup_printf(CLIENT_TAG, section);
+	client_tag = g_strdup_printf(CLIENT_TAG, whoami);
 	client = g_object_get_data(object, client_tag);
 	path = gnc_gconf_section_name(section);
 	if (client) {
-	  notify_tag = g_strdup_printf(NOTIFY_TAG, section);
+	  notify_tag = g_strdup_printf(NOTIFY_TAG, whoami);
 	  id = GPOINTER_TO_UINT(g_object_get_data(object, notify_tag));
 	  gconf_client_notify_remove(client, id);
 	  gconf_client_remove_dir(client, path, NULL);

Modified: gnucash/branches/2.0/src/core-utils/gnc-gconf-utils.h
===================================================================
--- gnucash/branches/2.0/src/core-utils/gnc-gconf-utils.h	2006-08-28 19:28:47 UTC (rev 14752)
+++ gnucash/branches/2.0/src/core-utils/gnc-gconf-utils.h	2006-08-29 03:26:36 UTC (rev 14753)
@@ -765,10 +765,15 @@
  *  @param callback The function to call when a value changes.  This
  *  function will receive the key/value pair as one argument, and the
  *  'object' argument to this function as another of its arguments.
+ *
+ *  @param whoami A magic value that must match up this call to the
+ *  corresponding call to gnc_gconf_remove_notification().  This value
+ *  should be unique across all callers.
  */
 void gnc_gconf_add_notification (GObject *object,
 				 const gchar *section,
-				 GConfClientNotifyFunc callback);
+				 GConfClientNotifyFunc callback,
+				 const gchar *whoami);
 
 
 /** An alternative function for adding a notification callback to
@@ -820,9 +825,14 @@
  *
  *  @param section This string is used to find the correct
  *  notification function to remove from GConf.
+ *
+ *  @param whoami A magic value that must match up this call to the
+ *  corresponding call to gnc_gconf_add_notification().  This value
+ *  should be unique across all callers.
  */
 void gnc_gconf_remove_notification (GObject *object,
-				    const gchar *section);
+				    const gchar *section,
+				    const gchar *whoami);
 
 
 

Modified: gnucash/branches/2.0/src/gnome-utils/dialog-preferences.c
===================================================================
--- gnucash/branches/2.0/src/gnome-utils/dialog-preferences.c	2006-08-28 19:28:47 UTC (rev 14752)
+++ gnucash/branches/2.0/src/gnome-utils/dialog-preferences.c	2006-08-29 03:26:36 UTC (rev 14753)
@@ -1264,7 +1264,8 @@
      gnc_save_window_size(GCONF_SECTION, GTK_WINDOW(dialog));
      gnc_unregister_gui_component_by_data(DIALOG_PREFERENCES_CM_CLASS,
 					  dialog);
-     gnc_gconf_remove_notification(G_OBJECT(dialog), NULL);
+     gnc_gconf_remove_notification(G_OBJECT(dialog), NULL,
+				   DIALOG_PREFERENCES_CM_CLASS);
      gtk_widget_destroy(GTK_WIDGET(dialog));
      break;
   }
@@ -1614,7 +1615,8 @@
   gtk_widget_show(dialog);
 
   gnc_gconf_add_notification(G_OBJECT(dialog), NULL,
-			     gnc_preferences_gconf_changed);
+			     gnc_preferences_gconf_changed,
+			     DIALOG_PREFERENCES_CM_CLASS);
   gnc_gconf_general_register_cb(KEY_ACCOUNT_SEPARATOR,
 				(GncGconfGeneralCb)gnc_account_separator_prefs_cb,
 				dialog);

Modified: gnucash/branches/2.0/src/gnome-utils/dialog-reset-warnings.c
===================================================================
--- gnucash/branches/2.0/src/gnome-utils/dialog-reset-warnings.c	2006-08-28 19:28:47 UTC (rev 14752)
+++ gnucash/branches/2.0/src/gnome-utils/dialog-reset-warnings.c	2006-08-29 03:26:36 UTC (rev 14753)
@@ -220,7 +220,8 @@
       break;
 
     case GTK_RESPONSE_OK:
-      gnc_gconf_remove_notification(G_OBJECT(dialog), GCONF_WARNINGS);
+      gnc_gconf_remove_notification(G_OBJECT(dialog), GCONF_WARNINGS,
+				    DIALOG_RESET_WARNINGS_CM_CLASS);
       gnc_reset_warnings_apply_changes(dialog);
       gnc_save_window_size(GCONF_SECTION, GTK_WINDOW(dialog));
       gnc_unregister_gui_component_by_data(DIALOG_RESET_WARNINGS_CM_CLASS,
@@ -229,7 +230,8 @@
       break;
 
     default:
-      gnc_gconf_remove_notification(G_OBJECT(dialog), GCONF_WARNINGS);
+      gnc_gconf_remove_notification(G_OBJECT(dialog), GCONF_WARNINGS,
+				    DIALOG_RESET_WARNINGS_CM_CLASS);
       gnc_reset_warnings_revert_changes(dialog);
       gnc_unregister_gui_component_by_data(DIALOG_RESET_WARNINGS_CM_CLASS,
 					   dialog);
@@ -404,7 +406,8 @@
   gnc_reset_warnings_update_widgets(dialog);
 
   gnc_gconf_add_notification(G_OBJECT(dialog), GCONF_WARNINGS,
-			     gnc_reset_warnings_gconf_changed);
+			     gnc_reset_warnings_gconf_changed,
+			     DIALOG_RESET_WARNINGS_CM_CLASS);
 
   gnc_restore_window_size(GCONF_SECTION, GTK_WINDOW(dialog));
 

Modified: gnucash/branches/2.0/src/gnome-utils/gnc-main-window.c
===================================================================
--- gnucash/branches/2.0/src/gnome-utils/gnc-main-window.c	2006-08-28 19:28:47 UTC (rev 14752)
+++ gnucash/branches/2.0/src/gnome-utils/gnc-main-window.c	2006-08-29 03:26:36 UTC (rev 14753)
@@ -1812,8 +1812,10 @@
 	  /* Update the "Windows" menu in all other windows */
 	  gnc_main_window_update_all_menu_items();
 
-	  gnc_gconf_remove_notification(G_OBJECT(window), DESKTOP_GNOME_INTERFACE);
-	  gnc_gconf_remove_notification(G_OBJECT(window), GCONF_GENERAL);
+	  gnc_gconf_remove_notification(G_OBJECT(window), DESKTOP_GNOME_INTERFACE,
+					GNC_MAIN_WINDOW_NAME);
+	  gnc_gconf_remove_notification(G_OBJECT(window), GCONF_GENERAL,
+					GNC_MAIN_WINDOW_NAME);
 
 	  qof_event_unregister_handler(priv->event_handler_id);
 	  priv->event_handler_id = 0;
@@ -2688,9 +2690,11 @@
 	g_free(filename);
 
 	gnc_gconf_add_notification(G_OBJECT(window), GCONF_GENERAL,
-				   gnc_main_window_gconf_changed);
+				   gnc_main_window_gconf_changed,
+				   GNC_MAIN_WINDOW_NAME);
 	gnc_gconf_add_notification(G_OBJECT(window), DESKTOP_GNOME_INTERFACE,
-				   gnc_main_window_gconf_changed);
+				   gnc_main_window_gconf_changed,
+				   GNC_MAIN_WINDOW_NAME);
 	gnc_main_window_update_toolbar(window);
 
 	gnc_main_window_init_menu_updaters(window);

Modified: gnucash/branches/2.0/src/gnome-utils/gnc-plugin.c
===================================================================
--- gnucash/branches/2.0/src/gnome-utils/gnc-plugin.c	2006-08-28 19:28:47 UTC (rev 14752)
+++ gnucash/branches/2.0/src/gnome-utils/gnc-plugin.c	2006-08-29 03:26:36 UTC (rev 14753)
@@ -85,7 +85,7 @@
 		};
 
 		gnc_plugin_type = g_type_register_static (G_TYPE_OBJECT,
-							  "GncPlugin",
+							  GNC_PLUGIN_NAME,
 							   &our_info, 0);
 	}
 
@@ -195,7 +195,7 @@
 	if (class->gconf_section && class->gconf_notifications) {
 	  DEBUG ("Requesting notification for section %s", class->gconf_section);
 	  gnc_gconf_add_notification(G_OBJECT(window), class->gconf_section,
-				     class->gconf_notifications);
+				     class->gconf_notifications, GNC_PLUGIN_NAME);
 	}
 
 	/*
@@ -241,7 +241,8 @@
 	 */
 	if (class->gconf_section && class->gconf_notifications) {
 	  DEBUG ("Remove notification for section %s", class->gconf_section);
-	  gnc_gconf_remove_notification (G_OBJECT(window), class->gconf_section);
+	  gnc_gconf_remove_notification (G_OBJECT(window), class->gconf_section,
+					 GNC_PLUGIN_NAME);
 	}
 
 	/*

Modified: gnucash/branches/2.0/src/gnome-utils/gnc-plugin.h
===================================================================
--- gnucash/branches/2.0/src/gnome-utils/gnc-plugin.h	2006-08-28 19:28:47 UTC (rev 14752)
+++ gnucash/branches/2.0/src/gnome-utils/gnc-plugin.h	2006-08-29 03:26:36 UTC (rev 14753)
@@ -93,6 +93,8 @@
 #define GNC_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_PLUGIN))
 #define GNC_PLUGIN_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_PLUGIN, GncPluginClass))
 
+#define GNC_PLUGIN_NAME "GncPlugin"
+
 /* typedefs & structures */
 
 /** The instance data structure for a menu-only plugin. */

Modified: gnucash/branches/2.0/src/gnome-utils/gnc-tree-view.c
===================================================================
--- gnucash/branches/2.0/src/gnome-utils/gnc-tree-view.c	2006-08-28 19:28:47 UTC (rev 14752)
+++ gnucash/branches/2.0/src/gnome-utils/gnc-tree-view.c	2006-08-29 03:26:36 UTC (rev 14753)
@@ -1191,7 +1191,8 @@
   }
 
   DEBUG("removing gconf notification");
-  gnc_gconf_remove_notification(G_OBJECT(view), priv->gconf_section);
+  gnc_gconf_remove_notification(G_OBJECT(view), priv->gconf_section,
+				GNC_TREE_VIEW_NAME);
   g_free(priv->gconf_section);
   priv->gconf_section = NULL;
   LEAVE(" ");
@@ -1228,7 +1229,8 @@
   priv = GNC_TREE_VIEW_GET_PRIVATE(view);
   priv->gconf_section = g_strdup(section);
   gnc_gconf_add_notification(G_OBJECT(view), section,
-			     gnc_tree_view_gconf_changed);
+			     gnc_tree_view_gconf_changed,
+			     GNC_TREE_VIEW_NAME);
 
   /* Catch changes to the sort column. Propagate to gconf. The key can
    * be set before the model, so the code must handle that case. */



More information about the gnucash-changes mailing list