glom r1547 - in branches/glom-1-6: . glom glom/libglom glom/libglom/document



Author: murrayc
Date: Thu Apr 10 10:47:49 2008
New Revision: 1547
URL: http://svn.gnome.org/viewvc/glom?rev=1547&view=rev

Log:
2008-04-10  Murray Cumming  <murrayc murrayc com>

* glom/libglom/connectionpool.cc (on_linux_signal): Call the 
previously-set SIGSEGV handler, to hopefully make bug-buddy or apport 
catch (and report) crashes again.

2008-04-10  Murray Cumming  <murrayc murrayc com>

* glom/libglom/spawn_with_feedback.h 
* glom/libglom/spawn_with_feedback.cc (get_and_show_pulse_dialog,
  execute_command_line_and_wait,
  execute_command_line_and_wait_until_second_command_returns_success):
* glom/libglom/connectionpool.h 
* glom/libglom/connectionpool.cc:
  start_self_hosting(), stop_self_hosting(), create_self_hosting():
Added parent_window parameter, so that any dialogs can be transient for 
it.

* glom/application.cc on_document_load(),
  stop_self_hosting_of_document_database(): Call 
start/stop_self_hosting() with the parent_window parameter.
* glom/frame_glom.cc:
  connection_request_password_and_choose_new_database_name():
* glom/libglom/document/document_glom.cc:
Call start/stop_self_hosting() with the parent_window parameter.

This should prevent these windows from being system-modal when using 
the xfwm4 window manager.
Bug #525285 (Jani Monoses) 

Modified:
   branches/glom-1-6/ChangeLog
   branches/glom-1-6/glom/application.cc
   branches/glom-1-6/glom/frame_glom.cc
   branches/glom-1-6/glom/libglom/connectionpool.cc
   branches/glom-1-6/glom/libglom/connectionpool.h
   branches/glom-1-6/glom/libglom/document/document_glom.cc
   branches/glom-1-6/glom/libglom/spawn_with_feedback.cc
   branches/glom-1-6/glom/libglom/spawn_with_feedback.h

Modified: branches/glom-1-6/glom/application.cc
==============================================================================
--- branches/glom-1-6/glom/application.cc	(original)
+++ branches/glom-1-6/glom/application.cc	Thu Apr 10 10:47:49 2008
@@ -791,7 +791,7 @@
     if(!connection_pool)
       return;
 
-    connection_pool->stop_self_hosting();
+    connection_pool->stop_self_hosting(this);
   }
 }
 #endif // !GLOM_ENABLE_CLIENT_ONLY
@@ -945,7 +945,7 @@
 
           if(!is_example) /* It will be started later, after we have asked for the initial db name/title and created the files.*/
           {
-            const bool test = connection_pool->start_self_hosting(); //Stopped in on_menu_file_close().
+            const bool test = connection_pool->start_self_hosting(this); //Stopped in on_menu_file_close().
             if(!test)
               return false;
           }

Modified: branches/glom-1-6/glom/frame_glom.cc
==============================================================================
--- branches/glom-1-6/glom/frame_glom.cc	(original)
+++ branches/glom-1-6/glom/frame_glom.cc	Thu Apr 10 10:47:49 2008
@@ -1583,7 +1583,7 @@
       created = dialog->create_self_hosted();
       if(created)
       {
-        const bool test = connection_pool->start_self_hosting();
+        const bool test = connection_pool->start_self_hosting(get_app_window());
         if(!test)
           return false;
       }

Modified: branches/glom-1-6/glom/libglom/connectionpool.cc
==============================================================================
--- branches/glom-1-6/glom/libglom/connectionpool.cc	(original)
+++ branches/glom-1-6/glom/libglom/connectionpool.cc	Thu Apr 10 10:47:49 2008
@@ -656,14 +656,19 @@
 
   if(signum == SIGSEGV)
   {
-    connection_pool->stop_self_hosting();
+    //TODO: Make this dialog transient for the parent window, 
+    //though this is obviously an unusual case.
+    connection_pool->stop_self_hosting(0 /* parent_window */);
 	
-    //TODO: How can we let GNOME's crash handler still handle this?
-    exit(1);
+    //Let GNOME/Ubuntu's crash handler still handle this?
+    if(previous_sig_handler)
+      (*previous_sig_handler)(signum);
+    else
+      exit(1);
   }
 }
 
-bool ConnectionPool::start_self_hosting()
+bool ConnectionPool::start_self_hosting(Gtk::Window* parent_window)
 {
   if(m_self_hosting_active)
     return true; //Just do it once.
@@ -725,7 +730,7 @@
   const std::string second_command_success_text = "is running"; //TODO: This is not a stable API. Also, watch out for localisation.
 
   //The first command does not return, but the second command can check whether it succeeded:
-  const bool result = Glom::Spawn::execute_command_line_and_wait_until_second_command_returns_success(command_postgres_start, command_check_postgres_has_started, _("Starting Database Server"), 0 /* window*/, second_command_success_text);
+  const bool result = Glom::Spawn::execute_command_line_and_wait_until_second_command_returns_success(command_postgres_start, command_check_postgres_has_started, _("Starting Database Server"), parent_window, second_command_success_text);
   if(!result)
   {
     std::cerr << "Error while attempting to self-host a database." << std::endl;
@@ -744,7 +749,7 @@
   return true;
 }
 
-void ConnectionPool::stop_self_hosting()
+void ConnectionPool::stop_self_hosting(Gtk::Window* parent_window)
 {
   if(!m_self_hosting_active)
     return; //Don't try to stop it if we have not started it.
@@ -769,14 +774,14 @@
   // We use "-m fast" instead of the default "-m smart" because that waits for clients to disconnect (and sometimes never succeeds).
   // TODO: Warn about connected clients on other computers? Warn those other users?
   const std::string command_postgres_stop = POSTGRES_UTILS_PATH "/pg_ctl -D \"" + dbdir_data + "\" stop -m fast";
-  const bool result = Glom::Spawn::execute_command_line_and_wait(command_postgres_stop, _("Stopping Database Server"));
+  const bool result = Glom::Spawn::execute_command_line_and_wait(command_postgres_stop, _("Stopping Database Server"), parent_window);
   if(!result)
   {
     std::cerr << "Error while attempting to stop self-hosting of the database. Trying again."  << std::endl;
 
     //I've seen it fail when running under valgrind, and there are reports of failures in bug #420962.
     //Maybe it will help to try again:
-    const bool result = Glom::Spawn::execute_command_line_and_wait(command_postgres_stop, _("Stopping Database Server (retrying)"));
+    const bool result = Glom::Spawn::execute_command_line_and_wait(command_postgres_stop, _("Stopping Database Server (retrying)"), parent_window);
     if(!result)
     {
       std::cerr << "Error while attempting (for a second time) to stop self-hosting of the database."  << std::endl;
@@ -875,7 +880,7 @@
   const std::string command_initdb = POSTGRES_UTILS_PATH "/initdb -D \"" + dbdir_data + "\"" +
                                         " -U " + username + " --pwfile=\"" + temp_pwfile + "\""; 
   //Note that --pwfile takes the password from the first line of a file. It's an alternative to supplying it when prompted on stdin.
-  const bool result = Glom::Spawn::execute_command_line_and_wait(command_initdb, _("Creating Database Data"));
+  const bool result = Glom::Spawn::execute_command_line_and_wait(command_initdb, _("Creating Database Data"), parent_window);
   if(!result)
   {
     std::cerr << "Error while attempting to create self-hosting database." << std::endl;

Modified: branches/glom-1-6/glom/libglom/connectionpool.h
==============================================================================
--- branches/glom-1-6/glom/libglom/connectionpool.h	(original)
+++ branches/glom-1-6/glom/libglom/connectionpool.h	Thu Apr 10 10:47:49 2008
@@ -160,12 +160,15 @@
 
 #ifndef GLOM_ENABLE_CLIENT_ONLY
   /** Start a database server instance for the exisiting database files.
+   * @param parent_window The parent window (transient for) of any dialogs shown during this operation.
+   * @result Whether the operation was successful.
    */
-  bool start_self_hosting();
+  bool start_self_hosting(Gtk::Window* parent_window);
 
   /** Stop the database server instance for the database files.
+   * @param parent_window The parent window (transient for) of any dialogs shown during this operation.
    */
-  void stop_self_hosting();
+  void stop_self_hosting(Gtk::Window* parent_window);
 
   /** Create new database files, for later use by their own  database server instance.
    * @param parent_window A parent window to use as the transient window when displaying errors.

Modified: branches/glom-1-6/glom/libglom/document/document_glom.cc
==============================================================================
--- branches/glom-1-6/glom/libglom/document/document_glom.cc	(original)
+++ branches/glom-1-6/glom/libglom/document/document_glom.cc	Thu Apr 10 10:47:49 2008
@@ -223,7 +223,7 @@
     if(!connection_pool)
       return;
 
-    connection_pool->stop_self_hosting();
+    connection_pool->stop_self_hosting(m_parent_window);
   }
 #endif // !GLOM_ENABLE_CLIENT_ONLY
 }

Modified: branches/glom-1-6/glom/libglom/spawn_with_feedback.cc
==============================================================================
--- branches/glom-1-6/glom/libglom/spawn_with_feedback.cc	(original)
+++ branches/glom-1-6/glom/libglom/spawn_with_feedback.cc	Thu Apr 10 10:47:49 2008
@@ -132,6 +132,9 @@
 
 static Dialog_ProgressCreating* get_and_show_pulse_dialog(const Glib::ustring& message, Gtk::Window* parent_window)
 {
+  if(!parent_window)
+    std::cerr << "debug: Glom: get_and_show_pulse_dialog(): parent_window is NULL" << std::endl;
+
 #ifdef GLIBMM_EXCEPTIONS_ENABLED
   Glib::RefPtr<Gnome::Glade::Xml> refXml = Gnome::Glade::Xml::create(GLOM_GLADEDIR "glom.glade", "window_progress");
 #else
@@ -169,6 +172,9 @@
 
 bool execute_command_line_and_wait(const std::string& command, const Glib::ustring& message, Gtk::Window* parent_window)
 {
+  if(!parent_window)
+    std::cerr << "debug: Glom: execute_command_line_and_wait(): parent_window is NULL" << std::endl;
+
   //Show a dialog with a pulsing progress bar and a human-readable message, while we wait for the command to finish:
   //
   //Put the dialog in an auto_ptr so that it will be deleted (and hidden) when the current function returns.
@@ -176,15 +182,15 @@
   std::auto_ptr<Dialog_ProgressCreating> dialog_progress;
   dialog_progress.reset(dialog_temp);
 
-
-  std::cout << std::endl << "debug: command_line: " << command << std::endl << std::endl;
-
   return pulse_until_thread_finished(*dialog_progress, command, sigc::ptr_fun(&execute_command_line_on_thread_create) );
 }
 
 
 bool execute_command_line_and_wait_until_second_command_returns_success(const std::string& command, const std::string& second_command, const Glib::ustring& message, Gtk::Window* parent_window, const std::string& success_text)
 {
+  if(!parent_window)
+    std::cerr << "debug: Glom: execute_command_line_and_wait_until_second_command_returns_success(): parent_window is NULL" << std::endl;
+
   Dialog_ProgressCreating* dialog_temp = get_and_show_pulse_dialog(message, parent_window);
   std::auto_ptr<Dialog_ProgressCreating> dialog_progress;
   dialog_progress.reset(dialog_temp);
@@ -299,7 +305,7 @@
   while(Gtk::Main::instance()->events_pending())
     Gtk::Main::instance()->iteration();
 
-  std::cout << std::endl << "debug: command_line: " << command << std::endl << std::endl;
+  std::cout << std::endl << "  debug: command_line: " << command << std::endl << std::endl;
 
   try
   {

Modified: branches/glom-1-6/glom/libglom/spawn_with_feedback.h
==============================================================================
--- branches/glom-1-6/glom/libglom/spawn_with_feedback.h	(original)
+++ branches/glom-1-6/glom/libglom/spawn_with_feedback.h	Thu Apr 10 10:47:49 2008
@@ -35,7 +35,7 @@
  * @param message A human-readable message to be shown, for instance in a dialog, while waiting.
  * @parent_window Make the dialog transient to this window.
  */
-bool execute_command_line_and_wait(const std::string& command, const Glib::ustring& message, Gtk::Window* parent_window = 0);
+bool execute_command_line_and_wait(const std::string& command, const Glib::ustring& message, Gtk::Window* parent_window);
 
 /** Execute a command-line command, and repeatedly call a second command that tests whether the first command has finished.
  * @param command The command-line command.
@@ -43,9 +43,9 @@
  * @parent_window Make the dialog transient to this window.
  * @success_text If this is not empty, then the second command will only be considered to have succeeded when this text is found in its stdout output.
  */
-bool execute_command_line_and_wait_until_second_command_returns_success(const std::string& command, const std::string& second_command, const Glib::ustring& message, Gtk::Window* parent_window = 0, const std::string& success_text = std::string());
+bool execute_command_line_and_wait_until_second_command_returns_success(const std::string& command, const std::string& second_command, const Glib::ustring& message, Gtk::Window* parent_window, const std::string& success_text = std::string());
 
-//bool execute_command_line_and_wait_fixed_seconds(const std::string& command, unsigned int seconds, const Glib::ustring& message, Gtk::Window* parent_window = 0);
+//bool execute_command_line_and_wait_fixed_seconds(const std::string& command, unsigned int seconds, const Glib::ustring& message, Gtk::Window* parent_window);
 
 
 } //Spawn



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