[glom] Field Definitions: Default value: Fix crash when selecting a date.



commit fd84aaf53d0aa7486c04f4f373da4444019876e7
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Dec 4 09:45:50 2009 +0100

    Field Definitions: Default value: Fix crash when selecting a date.
    
    * glom/utility_widgets/datawidget.cc: offer_field_list(),
    offer_field_layout(), offer_related_record_id_find(): Avoid crashes
    caused by calling set_transient_for() with a null parent window,
    for instance from the field definitions dialog.

 ChangeLog                          |    9 +++++++++
 glom/libglom/connectionpool.cc     |    2 +-
 glom/utility_widgets/datawidget.cc |   20 +++++++++++++++-----
 3 files changed, 25 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7fd7c2c..61810af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2009-12-04  Murray Cumming  <murrayc murrayc com>
 
+	Field Definitions: Default value: Fix crash when selecting a date.
+
+	* glom/utility_widgets/datawidget.cc: offer_field_list(), 
+	offer_field_layout(), offer_related_record_id_find(): Avoid crashes 
+	caused by calling set_transient_for() with a null parent window, 
+	for instance from the field definitions dialog.
+
+2009-12-04  Murray Cumming  <murrayc murrayc com>
+
 	Field Definitions: Show default value widget for date fields.
 
 	* glom/utility_widgets/datawidget.cc: Constructor: show the 
diff --git a/glom/libglom/connectionpool.cc b/glom/libglom/connectionpool.cc
index 0f2f2ea..38f6d7d 100644
--- a/glom/libglom/connectionpool.cc
+++ b/glom/libglom/connectionpool.cc
@@ -535,7 +535,7 @@ bool ConnectionPool::startup(const SlotProgress& slot_progress, bool network_sha
 
   //If we crash while running (unlikely, hopefully), then try to cleanup.
   //Comment this out if you want to see the backtrace in a debugger.
-  previous_sig_handler = signal(SIGSEGV, &on_linux_signal);
+  //previous_sig_handler = signal(SIGSEGV, &on_linux_signal);
 
   return true;
 }
diff --git a/glom/utility_widgets/datawidget.cc b/glom/utility_widgets/datawidget.cc
index df7497d..11aede8 100644
--- a/glom/utility_widgets/datawidget.cc
+++ b/glom/utility_widgets/datawidget.cc
@@ -597,8 +597,10 @@ sharedptr<LayoutItem_Field> DataWidget::offer_field_list(const Glib::ustring& ta
   if(dialog)
   {
     dialog->set_document(document, table_name, start_field);
-    dialog->set_transient_for(*app);
-    int response = dialog->run();
+    if(app)
+      dialog->set_transient_for(*app);
+
+    const int response = dialog->run();
     dialog->hide();
     if(response == Gtk::RESPONSE_OK)
     {
@@ -627,7 +629,11 @@ sharedptr<LayoutItem_Field> DataWidget::offer_field_layout(const sharedptr<const
     {
       add_view(dialog); //Give it access to the document.
       dialog->set_field(start_field, m_table_name);
-      dialog->set_transient_for(*get_application());
+
+      Gtk::Window* parent = get_application();
+      if(parent)
+        dialog->set_transient_for(*parent);
+
       const int response = dialog->run();
       dialog->hide();
       if(response == Gtk::RESPONSE_OK)
@@ -768,7 +774,9 @@ void DataWidget::on_button_choose_date()
 
   if(dialog)
   {
-    dialog->set_transient_for(*get_application());
+    Gtk::Window* parent = get_application(); //This doesn't work (and would be wrong) when the widget is in a Field Definitions dialog.
+    if(parent)
+      dialog->set_transient_for(*parent);
     dialog->set_date_chosen(get_value());
 
     const int response = Glom::Utils::dialog_run_with_help(dialog, "dialog_choose_date");
@@ -826,7 +834,9 @@ bool DataWidget::offer_related_record_id_find(Gnome::Gda::Value& chosen_id)
   if(dialog)
   {
     //dialog->set_document(get_document(), table_name, field);
-    dialog->set_transient_for(*get_application());
+    Gtk::Window* parent = get_application();
+    if(parent)
+      dialog->set_transient_for(*parent);
     add_view(dialog);
 
     //Discover the related table, in the relationship that uses this ID field:



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