[glom] Avoid "m_backend is NULL" warning at startup.



commit ff21cc98a1d1f3c57f6e3527d6c60c6dacba4f7d
Author: Murray Cumming <murrayc murrayc com>
Date:   Wed Sep 21 11:06:31 2011 +0200

    Avoid "m_backend is NULL" warning at startup.
    
    	* glom/libglom/connectionpool.[h|cc]: Added get_instance_is_ready().
    	* glom/application.cc: update_userlevel_ui(): Use it, because it might not
    	be ready, causing a (harmless) stderr warning.

 ChangeLog                      |    8 ++++++++
 glom/application.cc            |   11 +++++++----
 glom/libglom/connectionpool.cc |    8 ++++++++
 glom/libglom/connectionpool.h  |    4 ++++
 4 files changed, 27 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7f8da5e..5692bb7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-09-21  Murray Cumming  <murrayc murrayc com>
+
+	Avoid "m_backend is NULL" warning at startup.
+
+	* glom/libglom/connectionpool.[h|cc]: Added get_instance_is_ready().
+	* glom/application.cc: update_userlevel_ui(): Use it, because it might not 
+	be ready, causing a (harmless) stderr warning.
+
 1.19.11:
 
 2011-09-21  Murray Cumming  <murrayc murrayc com>
diff --git a/glom/application.cc b/glom/application.cc
index 25f3c6e..750a901 100644
--- a/glom/application.cc
+++ b/glom/application.cc
@@ -1412,14 +1412,17 @@ void Application::update_userlevel_ui()
   // support users
   if(userlevel == AppState::USERLEVEL_DEVELOPER)
   {
-    sharedptr<SharedConnection> connection = ConnectionPool::get_and_connect();
-    if(connection && !connection->get_gda_connection()->supports_feature(Gnome::Gda::CONNECTION_FEATURE_USERS))
-      m_action_developer_users->set_sensitive(false);
+    if(ConnectionPool::get_instance_is_ready())
+    {
+      sharedptr<SharedConnection> connection = ConnectionPool::get_and_connect();
+      if(connection && !connection->get_gda_connection()->supports_feature(Gnome::Gda::CONNECTION_FEATURE_USERS))
+        m_action_developer_users->set_sensitive(false);
+    }
   }
 
   //Make sure that the correct radio menu item is activated (the userlevel might have been set programmatically):
   //We only need to set/unset one, because the others are in the same radio group.
-  if(userlevel ==  AppState::USERLEVEL_DEVELOPER)
+  if(userlevel == AppState::USERLEVEL_DEVELOPER)
   {
     if(!m_action_menu_developer_developer->get_active())
       m_action_menu_developer_developer->set_active();
diff --git a/glom/libglom/connectionpool.cc b/glom/libglom/connectionpool.cc
index 1713034..b4f4b41 100644
--- a/glom/libglom/connectionpool.cc
+++ b/glom/libglom/connectionpool.cc
@@ -225,6 +225,14 @@ sharedptr<SharedConnection> ConnectionPool::get_and_connect()
   return result;
 }
 
+bool ConnectionPool::get_instance_is_ready()
+{
+  ConnectionPool* instance = get_instance();
+  if(!instance)
+    return false;
+
+  return instance->get_ready_to_connect();
+}
 
 
 // Store the connection for a few seconds in case it
diff --git a/glom/libglom/connectionpool.h b/glom/libglom/connectionpool.h
index 5a6f8cc..84338a4 100644
--- a/glom/libglom/connectionpool.h
+++ b/glom/libglom/connectionpool.h
@@ -98,6 +98,10 @@ public:
    * Use delete_instance() when the program quits.
    */
   static ConnectionPool* get_instance();
+  
+  /** Whether the connection is ready to be used.
+   */ 
+  static bool get_instance_is_ready();
 
   /** Make the ConnectionPool use the correct backend, with the necessary details,
    * as required by the document.



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