Save changes when toggling checkboxes in ExportDialog
authorTim Mayberry <mojofunk@gmail.com>
Sat, 17 Sep 2016 10:28:34 +0000 (20:28 +1000)
committerTim Mayberry <mojofunk@gmail.com>
Sat, 17 Sep 2016 12:03:16 +0000 (22:03 +1000)
I used the Widget::on_hide method in the ExportFileDialog to defer the saving
of changes in state of the analysis and soundcloud-upload checkboxes as it was
not possible to save the format xml state directly from the
ToggleButton::toggled() signal as it created a recursive loop and also to
prevent saving the state more than once.

Even though the ExportProfileManager::FormatListChanged signal is no longer
emitted when saving format state and the crash no longer occurs without this
change. I think it is worth saving explicitily from in the toggle callbacks to
reduce the complexity of understanding what is taking place and when even if it
is less efficient.

There is definitely more opportunity for refactoring and redesign.

gtk2_ardour/export_file_notebook.cc
gtk2_ardour/export_file_notebook.h

index 94f6f7f08a314a9ef1c17d32049ca29ef3ed59a5..a3af969740bb3a5535762b164b6c07aa36d8e8a3 100644 (file)
@@ -112,21 +112,11 @@ ExportFileNotebook::update_soundcloud_upload ()
        soundcloud_export_selector->set_visible (show_credentials_entry);
 }
 
-void
-ExportFileNotebook::FilePage::on_hide ()
-{
-       VBox::on_hide ();
-       if (save_format_on_hide) {
-               profile_manager->save_format_to_disk (format_state->format);
-               save_format_on_hide = false;
-       }
-}
-
 void
 ExportFileNotebook::FilePage::analysis_changed ()
 {
        format_state->format->set_analyse (analysis_button.get_active ());
-       save_format_on_hide = true;
+       profile_manager->save_format_to_disk (format_state->format);
 }
 
 void
@@ -216,8 +206,7 @@ ExportFileNotebook::FilePage::FilePage (Session * s, ManagerPtr profile_manager,
   filename_label (_("Location"), Gtk::ALIGN_LEFT),
   soundcloud_upload_button (_("Upload to Soundcloud")),
   analysis_button (_("Analyze Exported Audio")),
-  tab_number (number),
-  save_format_on_hide(false)
+  tab_number (number)
 {
        set_border_width (12);
 
@@ -315,7 +304,7 @@ ExportFileNotebook::FilePage::get_soundcloud_upload () const
 void
 ExportFileNotebook::FilePage::soundcloud_upload_changed ()
 {
-       save_format_on_hide = true;
+       profile_manager->save_format_to_disk (format_state->format);
 }
 
 void
index 3588197469c8bdfc354c6d87373ace26726f1eba..84d05c102548b66cc95e162801b21f7d5d351433 100644 (file)
@@ -100,8 +100,6 @@ class ExportFileNotebook : public Gtk::Notebook, public ARDOUR::SessionHandlePtr
                void analysis_changed ();
                void soundcloud_upload_changed ();
 
-               void on_hide ();
-
                ARDOUR::ExportProfileManager::FormatStatePtr   format_state;
                ARDOUR::ExportProfileManager::FilenameStatePtr filename_state;
                ManagerPtr                                     profile_manager;
@@ -124,8 +122,6 @@ class ExportFileNotebook : public Gtk::Notebook, public ARDOUR::SessionHandlePtr
                Gtk::Alignment          tab_close_alignment;
                Gtk::Button             tab_close_button;
                uint32_t                tab_number;
-
-               bool                    save_format_on_hide;
        };
 };