Prevent crashes when coming out of the add screen dialog without giving a certificate.
authorCarl Hetherington <cth@carlh.net>
Mon, 14 Oct 2013 11:46:15 +0000 (12:46 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 14 Oct 2013 11:46:15 +0000 (12:46 +0100)
ChangeLog
src/wx/kdm_dialog.cc
src/wx/screen_dialog.cc
src/wx/screen_dialog.h

index e870f50f092f6cd2bfb6d8f71126cc1eba11a23a..f7532998cd2dd51ffeafd81968eca12887015b25 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-10-14  Carl Hetherington  <cth@carlh.net>
+
+       * Fix some crashes in the KDM dialogue when coming
+       out of the add screen without giving a certificate.
+
 2013-10-13  Carl Hetherington  <cth@carlh.net>
 
        * Version 1.14 released.
@@ -7,7 +12,7 @@
        * Add some missing libraries to the OS X build.
 
 2013-10-12  Carl Hetherington  <cth@carlh.net>
-       
+
        * Version 1.13 released.
 
 2013-10-12  Carl Hetherington  <cth@carlh.net>
index 6164f7fd95d0b6aea94837d14943b1b8c095f219..02b91a1e2aa3e30b4fa479230b7b74d8b0cd02de 100644 (file)
@@ -276,7 +276,9 @@ KDMDialog::add_screen_clicked ()
        shared_ptr<Cinema> c = selected_cinemas().front().second;
        
        ScreenDialog* d = new ScreenDialog (this, "Add Screen");
-       d->ShowModal ();
+       if (d->ShowModal () != wxID_OK) {
+               return;
+       }
 
        shared_ptr<Screen> s (new Screen (d->name(), d->certificate()));
        c->add_screen (s);
index 6584e1ad6e92ba1b8a04a34ab761efdfa332b03b..32a0bce43f12ac0345920a2aa28bda00137f5621 100644 (file)
@@ -65,7 +65,9 @@ ScreenDialog::ScreenDialog (wxWindow* parent, string title, string name, shared_
        overall_sizer->Layout ();
        overall_sizer->SetSizeHints (this);
 
-       _certificate_load->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (ScreenDialog::load_certificate), 0, this);
+       _certificate_load->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ScreenDialog::load_certificate, this));
+
+       setup_sensitivity ();
 }
 
 string
@@ -81,7 +83,7 @@ ScreenDialog::certificate () const
 }
 
 void
-ScreenDialog::load_certificate (wxCommandEvent &)
+ScreenDialog::load_certificate ()
 {
        wxFileDialog* d = new wxFileDialog (this, _("Select Certificate File"));
 
@@ -95,4 +97,13 @@ ScreenDialog::load_certificate (wxCommandEvent &)
        }
        
        d->Destroy ();
+
+       setup_sensitivity ();
+}
+
+void
+ScreenDialog::setup_sensitivity ()
+{
+       wxButton* ok = dynamic_cast<wxButton*> (FindWindowById (wxID_OK, this));
+       ok->Enable (_certificate);
 }
index 1bd4a89a92cb976002ac735bd3371b1be26d579f..271ae2055a884123bb916004f7602f41c444319f 100644 (file)
@@ -30,7 +30,8 @@ public:
        boost::shared_ptr<libdcp::Certificate> certificate () const;
        
 private:
-       void load_certificate (wxCommandEvent &);
+       void load_certificate ();
+       void setup_sensitivity ();
        
        wxTextCtrl* _name;
        wxButton* _certificate_load;