[hardware-monitor] 2010-04-04 Neil Bird <neilbird src gnome org>



commit d972139a40ca1c44b1252c62889fbf2b34d5cd97
Author: Neil Bird <neilbird src gnome org>
Date:   Tue Apr 6 18:04:45 2010 +0100

    2010-04-04  Neil Bird  <neilbird src gnome org>
    
    	Start-up crash fix when when used with newer GConf
    
    	* MAINTAINERS: Add myself as new maintainer
    	* src/applet.cpp: Cope will NULL return for non-existent prefs.

 ChangeLog      |    7 +++++++
 MAINTAINERS    |    4 ++++
 src/applet.cpp |   26 ++++++++++++++++++++++++++
 3 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 4b7a67c..876679c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-04-04  Neil Bird  <neilbird src gnome org>
+
+	Start-up crash fix when when used with newer GConf
+
+	* MAINTAINERS: Add myself as new maintainer
+	* src/applet.cpp: Cope will NULL return for non-existent prefs.
+
 2009-05-02  Ole Laursen  <olau hardworking dk>
 
 	* NEWS: Released v. 1.4.2.
diff --git a/MAINTAINERS b/MAINTAINERS
index 407da1a..a978c2c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1,3 +1,7 @@
 Ole Laursen
 Email: olau hardworking dk
 Userid: olau
+
+Neil Bird
+Email: neilbird src gnome org
+Userid: neilbird
diff --git a/src/applet.cpp b/src/applet.cpp
index dae05b5..b3555ec 100644
--- a/src/applet.cpp
+++ b/src/applet.cpp
@@ -57,6 +57,25 @@ void display_about(BonoboUIComponent *, void *applet, const gchar *)
 }
 
 
+namespace
+{
+  template <typename T>
+    Gnome::Conf::Entry get_entry_with_default(
+      Glib::RefPtr<Gnome::Conf::Client> &gconf_client,
+      const Glib::ustring &key,
+      const T &value )
+    {
+      Gnome::Conf::Entry entry = gconf_client->get_entry(key);
+      if (!entry.gobj())
+      {
+        gconf_client->set( key, value );
+        entry = gconf_client->get_entry(key);
+      }
+      return entry;
+    }
+}
+
+
 Applet::Applet(PanelApplet *a)
   : panel_applet(a)
 {
@@ -128,6 +147,13 @@ Applet::Applet(PanelApplet *a)
   panel_applet_setup_menu(panel_applet, menu_xml, menu_verbs, this);
   
   // start displaying something
+  // Ensure config values aren't null
+  get_entry_with_default( gconf_client, gconf_dir + "/viewer_type",
+    Glib::ustring("curve") );
+  get_entry_with_default( gconf_client, gconf_dir + "/background_color",
+    0x00000000 );
+  get_entry_with_default( gconf_client, gconf_dir + "/use_background_color",
+    false );
   viewer_type_listener(0, gconf_client->get_entry(gconf_dir + "/viewer_type"));
   background_color_listener(0, gconf_client->get_entry(gconf_dir
 						       + "/background_color"));



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]