glom r1784 - in trunk: . glom/libglom



Author: murrayc
Date: Mon Dec  8 17:45:35 2008
New Revision: 1784
URL: http://svn.gnome.org/viewvc/glom?rev=1784&view=rev

Log:
2008-12-08  Murray Cumming  <murrayc murrayc com>

* glom/libglom/connectionpool.cc: cleanup(): Check for a null 
m_backend, to avoid a crash when quitting Glom without opening a file.
I added some more checks elsewhere.

Modified:
   trunk/ChangeLog
   trunk/glom/libglom/connectionpool.cc

Modified: trunk/glom/libglom/connectionpool.cc
==============================================================================
--- trunk/glom/libglom/connectionpool.cc	(original)
+++ trunk/glom/libglom/connectionpool.cc	Mon Dec  8 17:45:35 2008
@@ -339,7 +339,9 @@
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
       std::auto_ptr<ExceptionConnection> error;
 #endif
-      m_refGdaConnection = m_backend->connect(m_database, get_user(), get_password(), error);
+      if(m_backend.get())
+        m_refGdaConnection = m_backend->connect(m_database, get_user(), get_password(), error);
+
       if(!m_refGdaConnection)
       {
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
@@ -391,7 +393,9 @@
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
   std::auto_ptr<Glib::Error> error;
 #endif
-  m_backend->create_database(database_name, get_user(), get_password(), error);
+  if(m_backend.get())  
+    m_backend->create_database(database_name, get_user(), get_password(), error);
+
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
   if(error.get()) throw *error;
 #endif
@@ -566,6 +570,9 @@
 
 bool ConnectionPool::startup(Gtk::Window* parent_window)
 {
+  if(!m_backend.get())
+    return false;
+
   if(!m_backend->startup(parent_window))
     return false;
 
@@ -582,7 +589,8 @@
 
 void ConnectionPool::cleanup(Gtk::Window* parent_window)
 {
-  m_backend->cleanup(parent_window);
+  if(m_backend.get())
+    m_backend->cleanup(parent_window);
 
 #ifndef G_OS_WIN32
   /* Stop advertising the self-hosting database server via avahi: */
@@ -596,7 +604,10 @@
 
 bool ConnectionPool::initialize(Gtk::Window* parent_window)
 {
-  return m_backend->initialize(parent_window, get_user(), get_password());
+  if(m_backend.get())
+    return m_backend->initialize(parent_window, get_user(), get_password());
+  else
+    return false;
 }
 
 bool ConnectionPool::check_user_is_not_root()
@@ -691,6 +702,7 @@
 
   //std::cout << "ConnectionPool::on_publisher_document_authentication(): username=" << user_name << ", password=" << password << std::endl;
 
+  g_return_val_if_fail(connection_pool->m_backend.get(), FALSE);
  
   //Attempt a connection with this username/password:
   std::auto_ptr<ExceptionConnection> error;



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