[glom] Dialog_Layout_Report: Fix a crash, making all tests pass.



commit dc97a9ed1fef40da14d68c24a626e5b44aa30728
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Sep 10 11:21:49 2010 +0200

    Dialog_Layout_Report: Fix a crash, making all tests pass.
    
    * glom/mode_design/report_layout/dialog_layout_report.[h|cc]:
      Disconnect a signal handler in the destructor to avoid a crash when the
      GtkNotebook signal handler is called later, though we should fix that in
      GtkNotebook.

 ChangeLog                                          |   13 +++++++++++--
 .../report_layout/dialog_layout_report.cc          |   20 ++++++++++++--------
 .../report_layout/dialog_layout_report.h           |    1 +
 3 files changed, 24 insertions(+), 10 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8aaae75..ee32930 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,19 @@
+2010-09-10  Murray Cumming  <murrayc murrayc com>
+
+	Dialog_Layout_Report: Fix a crash, making all tests pass.
+
+	* glom/mode_design/report_layout/dialog_layout_report.[h|cc]:
+  Disconnect a signal handler in the destructor to avoid a crash when the
+  GtkNotebook signal handler is called later, though we should fix that in
+  GtkNotebook.
+
 2010-09-09  Murray Cumming  <murrayc murrayc com>
 
 	Choices drop-downs: More improvement of the column alignment.
 
 	* glom/mode_data/datawidget/comboentry.cc: create_model():
-	* glom/utility_widgets/db_adddel/cellrenderer_dblist.[h|cc]: 
-	on_editing_started(): Remove (with clear) the automatically-added 
+	* glom/utility_widgets/db_adddel/cellrenderer_dblist.[h|cc]:
+	on_editing_started(): Remove (with clear) the automatically-added
 	CellRenderer and re-pack it, so we can specify expand=false.
 
 2010-09-09  David King  <davidk openismus com>
diff --git a/glom/mode_design/report_layout/dialog_layout_report.cc b/glom/mode_design/report_layout/dialog_layout_report.cc
index 9147a04..ac51069 100644
--- a/glom/mode_design/report_layout/dialog_layout_report.cc
+++ b/glom/mode_design/report_layout/dialog_layout_report.cc
@@ -178,11 +178,15 @@ Dialog_Layout_Report::Dialog_Layout_Report(BaseObjectType* cobject, const Glib::
 
   show_all_children();
 
-  m_notebook_parts->signal_switch_page().connect(sigc::mem_fun(*this, &Dialog_Layout_Report::on_notebook_switch_page));
+  //We save the connection, so we can disconnect it in the destructor,
+  //because, for some reason, this signal handler is still called _after_ the destructor.
+  //TODO: Fix that problem in GTK+ or gtkmm?
+  m_signal_connection = m_notebook_parts->signal_switch_page().connect(sigc::mem_fun(*this, &Dialog_Layout_Report::on_notebook_switch_page));
 }
 
 Dialog_Layout_Report::~Dialog_Layout_Report()
 {
+  m_signal_connection.disconnect();
 }
 
 void Dialog_Layout_Report::setup_model(Gtk::TreeView& treeview, Glib::RefPtr<type_model>& model)
@@ -203,7 +207,7 @@ void Dialog_Layout_Report::setup_model(Gtk::TreeView& treeview, Glib::RefPtr<typ
 
   Gtk::CellRendererText* renderer_part = Gtk::manage(new Gtk::CellRendererText);
   column_part->pack_start(*renderer_part);
-  column_part->set_cell_data_func(*renderer_part, 
+  column_part->set_cell_data_func(*renderer_part,
     sigc::bind( sigc::mem_fun(*this, &Dialog_Layout_Report::on_cell_data_part), model));
 
   //Details column:
@@ -212,7 +216,7 @@ void Dialog_Layout_Report::setup_model(Gtk::TreeView& treeview, Glib::RefPtr<typ
 
   Gtk::CellRendererText* renderer_details = Gtk::manage(new Gtk::CellRendererText);
   column_details->pack_start(*renderer_details);
-  column_details->set_cell_data_func(*renderer_details, 
+  column_details->set_cell_data_func(*renderer_details,
     sigc::bind( sigc::mem_fun(*this, &Dialog_Layout_Report::on_cell_data_details), model));
 
 
@@ -345,7 +349,7 @@ void Dialog_Layout_Report::set_report(const Glib::ustring& table_name, const sha
   //Set the table name and title:
   m_label_table_name->set_text(table_name);
 
-  m_entry_name->set_text(report->get_name()); 
+  m_entry_name->set_text(report->get_name());
   m_entry_title->set_text(report->get_title());
   m_checkbutton_table_title->set_active(report->get_show_table_title());
 
@@ -445,7 +449,7 @@ void Dialog_Layout_Report::enable_buttons()
       bool enable_formatting = false;
       sharedptr<LayoutItem_Field> item_field = sharedptr<LayoutItem_Field>::cast_dynamic(layout_item_parent);
       if(item_field)
-        enable_formatting = true; 
+        enable_formatting = true;
 
       m_button_formatting->set_sensitive(enable_formatting);
 
@@ -891,10 +895,10 @@ void Dialog_Layout_Report::on_button_edit()
                 add_view(dialog);
                 dialog->set_item(group_by, m_table_name);
                 dialog->set_transient_for(*this);
-  
+
                 const int response = dialog->run();
                 dialog->hide();
-  
+
                 if(response == Gtk::RESPONSE_OK)
                 {
                   //Get the chosen relationship:
@@ -906,7 +910,7 @@ void Dialog_Layout_Report::on_button_edit()
                     m_modified = true;
                   }
                 }
-  
+
                 remove_view(dialog);
                 delete dialog;
               }
diff --git a/glom/mode_design/report_layout/dialog_layout_report.h b/glom/mode_design/report_layout/dialog_layout_report.h
index 1a4f7a3..055747c 100644
--- a/glom/mode_design/report_layout/dialog_layout_report.h
+++ b/glom/mode_design/report_layout/dialog_layout_report.h
@@ -124,6 +124,7 @@ private:
 
   Glib::ustring m_name_original;
   sharedptr<Report> m_report;
+  sigc::connection m_signal_connection;
 };
 
 } //namespace Glom



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