X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fkdm_dialog.cc;h=8f4f8622df0ca3dd93c43b7e326b2e93d97a4367;hb=773a9e0518f86b09cd1df81cef969a654c4018cf;hp=4975146ec87a998e5c6fa2ccbe0f3a8e6103e1c5;hpb=94201bd2a5a4cb391b7f2bdeba56b928fed7cfe1;p=dcpomatic.git diff --git a/src/wx/kdm_dialog.cc b/src/wx/kdm_dialog.cc index 4975146ec..8f4f8622d 100644 --- a/src/wx/kdm_dialog.cc +++ b/src/wx/kdm_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2014 Carl Hetherington + Copyright (C) 2012-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -273,8 +273,10 @@ KDMDialog::setup_sensitivity () _edit_screen->Enable (ss); _remove_screen->Enable (ss); - wxButton* ok = dynamic_cast (FindWindowById (wxID_OK)); - ok->Enable ((selected_cinemas().size() > 0 || selected_screens().size() > 0) && sd); + wxButton* ok = dynamic_cast (FindWindowById (wxID_OK, this)); + if (ok) { + ok->Enable ((selected_cinemas().size() > 0 || selected_screens().size() > 0) && sd); + } _folder->Enable (_write_to->GetValue ()); } @@ -309,11 +311,11 @@ void KDMDialog::add_cinema_clicked () { CinemaDialog* d = new CinemaDialog (this, "Add Cinema"); - d->ShowModal (); - - shared_ptr c (new Cinema (d->name(), d->email())); - Config::instance()->add_cinema (c); - add_cinema (c); + if (d->ShowModal () == wxID_OK) { + shared_ptr c (new Cinema (d->name(), d->email())); + Config::instance()->add_cinema (c); + add_cinema (c); + } d->Destroy (); } @@ -328,13 +330,12 @@ KDMDialog::edit_cinema_clicked () pair > c = selected_cinemas().front(); CinemaDialog* d = new CinemaDialog (this, "Edit cinema", c.second->name, c.second->email); - d->ShowModal (); - - c.second->name = d->name (); - c.second->email = d->email (); - _targets->SetItemText (c.first, std_to_wx (d->name())); - - Config::instance()->changed (); + if (d->ShowModal () == wxID_OK) { + c.second->name = d->name (); + c.second->email = d->email (); + _targets->SetItemText (c.first, std_to_wx (d->name())); + Config::instance()->changed (); + } d->Destroy (); } @@ -385,13 +386,12 @@ KDMDialog::edit_screen_clicked () pair > s = selected_screens().front(); ScreenDialog* d = new ScreenDialog (this, "Edit screen", s.second->name, s.second->certificate); - d->ShowModal (); - - s.second->name = d->name (); - s.second->certificate = d->certificate (); - _targets->SetItemText (s.first, std_to_wx (d->name())); - - Config::instance()->changed (); + if (d->ShowModal () == wxID_OK) { + s.second->name = d->name (); + s.second->certificate = d->certificate (); + _targets->SetItemText (s.first, std_to_wx (d->name())); + Config::instance()->changed (); + } d->Destroy (); } @@ -474,7 +474,7 @@ boost::filesystem::path KDMDialog::cpl () const { int const item = _cpl->GetSelection (); - assert (item >= 0); + DCPOMATIC_ASSERT (item >= 0); return _cpls[item].cpl_file; } @@ -493,7 +493,7 @@ KDMDialog::write_to () const dcp::Formulation KDMDialog::formulation () const { - return (dcp::Formulation) reinterpret_cast (_type->GetClientData (_type->GetSelection())); + return (dcp::Formulation) reinterpret_cast (_type->GetClientData (_type->GetSelection())); } void @@ -528,14 +528,17 @@ KDMDialog::update_cpl_summary () void KDMDialog::cpl_browse_clicked () { - wxFileDialog d (this, _("Select CPL XML file"), wxEmptyString, wxEmptyString, "*.xml"); - if (d.ShowModal() == wxID_CANCEL) { + wxFileDialog* d = new wxFileDialog (this, _("Select CPL XML file"), wxEmptyString, wxEmptyString, "*.xml"); + if (d->ShowModal() == wxID_CANCEL) { + d->Destroy (); return; } - boost::filesystem::path cpl_file (wx_to_std (d.GetPath ())); + boost::filesystem::path cpl_file (wx_to_std (d->GetPath ())); boost::filesystem::path dcp_dir = cpl_file.parent_path (); + d->Destroy (); + /* XXX: hack alert */ cxml::Document cpl_document ("CompositionPlaylist"); cpl_document.read_file (cpl_file);