summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-01-27 13:41:49 +0100
committerCarl Hetherington <cth@carlh.net>2023-01-27 13:41:49 +0100
commit7aab34abcab28ca38a5354dec075b56d430e82db (patch)
treea7a02355bb4ea08cdf652ccb89b4ee6d1247b5dd
parent526829ad670c19d5466555890d8afe8d7f744834 (diff)
More stack-allocated Dialog objects.
-rw-r--r--src/tools/dcpomatic_editor.cc15
-rw-r--r--src/wx/audio_panel.cc13
-rw-r--r--src/wx/file_picker_ctrl.cc9
-rw-r--r--src/wx/full_config_dialog.cc60
-rw-r--r--src/wx/job_view.cc5
-rw-r--r--src/wx/kdm_output_panel.cc18
-rw-r--r--src/wx/language_tag_dialog.cc10
-rw-r--r--src/wx/nag_dialog.cc7
-rw-r--r--src/wx/templates_dialog.cc21
-rw-r--r--src/wx/text_panel.cc7
-rw-r--r--src/wx/video_panel.cc28
11 files changed, 88 insertions, 105 deletions
diff --git a/src/tools/dcpomatic_editor.cc b/src/tools/dcpomatic_editor.cc
index 8e306551f..663eb8e3b 100644
--- a/src/tools/dcpomatic_editor.cc
+++ b/src/tools/dcpomatic_editor.cc
@@ -362,12 +362,12 @@ private:
void file_open ()
{
auto d = wxStandardPaths::Get().GetDocumentsDir();
- auto c = new wxDirDialog (this, _("Select DCP to open"), d, wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST);
+ wxDirDialog dialog(this, _("Select DCP to open"), d, wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST);
int r;
while (true) {
- r = c->ShowModal ();
- if (r == wxID_OK && c->GetPath() == wxStandardPaths::Get().GetDocumentsDir()) {
+ r = dialog.ShowModal();
+ if (r == wxID_OK && dialog.GetPath() == wxStandardPaths::Get().GetDocumentsDir()) {
error_dialog (this, _("You did not select a folder. Make sure that you select a folder before clicking Open."));
} else {
break;
@@ -375,11 +375,9 @@ private:
}
if (r == wxID_OK) {
- boost::filesystem::path const dcp (wx_to_std (c->GetPath ()));
+ boost::filesystem::path const dcp(wx_to_std(dialog.GetPath()));
load_dcp (dcp);
}
-
- c->Destroy ();
}
void file_save ()
@@ -394,9 +392,8 @@ private:
void help_about ()
{
- auto d = new AboutDialog (this);
- d->ShowModal ();
- d->Destroy ();
+ AboutDialog dialog(this);
+ dialog.ShowModal();
}
wxPanel* _overall_panel = nullptr;
diff --git a/src/wx/audio_panel.cc b/src/wx/audio_panel.cc
index 81a445efb..9a9043669 100644
--- a/src/wx/audio_panel.cc
+++ b/src/wx/audio_panel.cc
@@ -304,18 +304,17 @@ AudioPanel::film_content_changed (int property)
void
AudioPanel::gain_calculate_button_clicked ()
{
- auto d = new GainCalculatorDialog (this);
- auto const r = d->ShowModal ();
- auto c = d->db_change();
+ GainCalculatorDialog dialog(this);
+ auto const r = dialog.ShowModal();
+ auto change = dialog.db_change();
- if (r == wxID_CANCEL || !c) {
- d->Destroy ();
+ if (r == wxID_CANCEL || !change) {
return;
}
auto old_peak_dB = peak ();
auto old_value = _gain->wrapped()->GetValue();
- _gain->wrapped()->SetValue(old_value + *c);
+ _gain->wrapped()->SetValue(old_value + *change);
/* This appears to be necessary, as the change is not signalled,
I think.
@@ -328,8 +327,6 @@ AudioPanel::gain_calculate_button_clicked ()
_gain->wrapped()->SetValue (old_value);
_gain->view_changed ();
}
-
- d->Destroy ();
}
diff --git a/src/wx/file_picker_ctrl.cc b/src/wx/file_picker_ctrl.cc
index 284f7bc99..bf4877891 100644
--- a/src/wx/file_picker_ctrl.cc
+++ b/src/wx/file_picker_ctrl.cc
@@ -83,12 +83,11 @@ FilePickerCtrl::browse_clicked ()
if (_warn_overwrite) {
style |= wxFD_OVERWRITE_PROMPT;
}
- wxFileDialog* d = new wxFileDialog (this, _prompt, wxEmptyString, wxEmptyString, _wildcard, style);
- d->SetPath (_path);
- if (d->ShowModal () == wxID_OK) {
- SetPath (d->GetPath ());
+ wxFileDialog dialog(this, _prompt, wxEmptyString, wxEmptyString, _wildcard, style);
+ dialog.SetPath(_path);
+ if (dialog.ShowModal() == wxID_OK) {
+ SetPath(dialog.GetPath());
}
- d->Destroy ();
}
void
diff --git a/src/wx/full_config_dialog.cc b/src/wx/full_config_dialog.cc
index f7ed2b5be..7aea87c73 100644
--- a/src/wx/full_config_dialog.cc
+++ b/src/wx/full_config_dialog.cc
@@ -180,15 +180,14 @@ private:
void export_cinemas_file ()
{
- auto d = new wxFileDialog (
+ wxFileDialog dialog(
_panel, _("Select Cinemas File"), wxEmptyString, wxEmptyString, wxT("XML files (*.xml)|*.xml"),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT
);
- if (d->ShowModal () == wxID_OK) {
- boost::filesystem::copy_file(Config::instance()->cinemas_file(), wx_to_std(d->GetPath()), boost::filesystem::copy_option::overwrite_if_exists);
+ if (dialog.ShowModal() == wxID_OK) {
+ boost::filesystem::copy_file(Config::instance()->cinemas_file(), wx_to_std(dialog.GetPath()), boost::filesystem::copy_option::overwrite_if_exists);
}
- d->Destroy ();
}
#ifdef DCPOMATIC_HAVE_EBUR128_PATCHED_FFMPEG
@@ -222,11 +221,10 @@ private:
}
bool copy_and_link = true;
if (boost::filesystem::exists(new_file)) {
- auto d = new ConfigMoveDialog (_panel, new_file);
- if (d->ShowModal() == wxID_OK) {
+ ConfigMoveDialog dialog(_panel, new_file);
+ if (dialog.ShowModal() == wxID_OK) {
copy_and_link = false;
}
- d->Destroy ();
}
if (copy_and_link) {
@@ -974,31 +972,31 @@ private:
void send_test_email_clicked ()
{
- auto dialog = new SendTestEmailDialog(_panel);
- auto result = dialog->ShowModal();
- dialog->Destroy();
- if (result == wxID_OK) {
- Emailer emailer(
- wx_to_std(dialog->from()),
- { wx_to_std(dialog->to()) },
- wx_to_std(_("DCP-o-matic test email")),
- wx_to_std(_("This is a test email from DCP-o-matic."))
- );
- auto config = Config::instance();
- try {
- emailer.send (config->mail_server(), config->mail_port(), config->mail_protocol(), config->mail_user(), config->mail_password());
- } catch (NetworkError& e) {
- error_dialog (_panel, std_to_wx(e.summary()), std_to_wx(e.detail().get_value_or("")));
- return;
- } catch (std::exception& e) {
- error_dialog (_panel, _("Test email sending failed."), std_to_wx(e.what()));
- return;
- } catch (...) {
- error_dialog (_panel, _("Test email sending failed."));
- return;
- }
- message_dialog (_panel, _("Test email sent."));
+ SendTestEmailDialog dialog(_panel);
+ if (dialog.ShowModal() != wxID_OK) {
+ return;
+ }
+
+ Emailer emailer(
+ wx_to_std(dialog.from()),
+ { wx_to_std(dialog.to()) },
+ wx_to_std(_("DCP-o-matic test email")),
+ wx_to_std(_("This is a test email from DCP-o-matic."))
+ );
+ auto config = Config::instance();
+ try {
+ emailer.send(config->mail_server(), config->mail_port(), config->mail_protocol(), config->mail_user(), config->mail_password());
+ } catch (NetworkError& e) {
+ error_dialog(_panel, std_to_wx(e.summary()), std_to_wx(e.detail().get_value_or("")));
+ return;
+ } catch (std::exception& e) {
+ error_dialog(_panel, _("Test email sending failed."), std_to_wx(e.what()));
+ return;
+ } catch (...) {
+ error_dialog(_panel, _("Test email sending failed."));
+ return;
}
+ message_dialog(_panel, _("Test email sent."));
}
wxTextCtrl* _server;
diff --git a/src/wx/job_view.cc b/src/wx/job_view.cc
index 8dbe87652..b98555e8a 100644
--- a/src/wx/job_view.cc
+++ b/src/wx/job_view.cc
@@ -156,9 +156,8 @@ JobView::finished ()
}
if (_job->message()) {
- auto d = new MessageDialog (_parent, std_to_wx(_job->name()), std_to_wx(_job->message().get()));
- d->ShowModal ();
- d->Destroy ();
+ MessageDialog dialog(_parent, std_to_wx(_job->name()), std_to_wx(_job->message().get()));
+ dialog.ShowModal();
}
if (_job->enable_notify() && _notify->GetValue()) {
diff --git a/src/wx/kdm_output_panel.cc b/src/wx/kdm_output_panel.cc
index 96b97b163..e7374cff9 100644
--- a/src/wx/kdm_output_panel.cc
+++ b/src/wx/kdm_output_panel.cc
@@ -197,12 +197,11 @@ KDMOutputPanel::setup_sensitivity ()
void
KDMOutputPanel::advanced_clicked ()
{
- auto d = new KDMAdvancedDialog (this, _forensic_mark_video, _forensic_mark_audio, _forensic_mark_audio_up_to);
- d->ShowModal ();
- _forensic_mark_video = d->forensic_mark_video ();
- _forensic_mark_audio = d->forensic_mark_audio ();
- _forensic_mark_audio_up_to = d->forensic_mark_audio_up_to ();
- d->Destroy ();
+ KDMAdvancedDialog dialog(this, _forensic_mark_video, _forensic_mark_audio, _forensic_mark_audio_up_to);
+ dialog.ShowModal();
+ _forensic_mark_video = dialog.forensic_mark_video();
+ _forensic_mark_audio = dialog.forensic_mark_audio();
+ _forensic_mark_audio_up_to = dialog.forensic_mark_audio_up_to();
}
@@ -343,10 +342,9 @@ KDMOutputPanel::directory () const
void
KDMOutputPanel::add_email_addresses_clicked ()
{
- auto dialog = new ExtraKDMEmailDialog (this, _extra_addresses);
- if (dialog->ShowModal() == wxID_OK) {
- _extra_addresses = dialog->get();
+ ExtraKDMEmailDialog dialog(this, _extra_addresses);
+ if (dialog.ShowModal() == wxID_OK) {
+ _extra_addresses = dialog.get();
}
- dialog->Destroy();
}
diff --git a/src/wx/language_tag_dialog.cc b/src/wx/language_tag_dialog.cc
index a3ad847d5..b472edab0 100644
--- a/src/wx/language_tag_dialog.cc
+++ b/src/wx/language_tag_dialog.cc
@@ -75,13 +75,11 @@ LanguageTagDialog::LanguageTagDialog (wxWindow* parent, dcp::LanguageTag tag)
void
LanguageTagDialog::add_language ()
{
- auto full = new FullLanguageTagDialog (GetParent());
- auto r = full->ShowModal ();
- if (r == wxID_OK) {
- Config::instance()->add_custom_language (full->get());
- set (full->get());
+ FullLanguageTagDialog full(GetParent());
+ if (full.ShowModal() == wxID_OK) {
+ Config::instance()->add_custom_language(full.get());
+ set(full.get());
}
- full->Destroy ();
}
diff --git a/src/wx/nag_dialog.cc b/src/wx/nag_dialog.cc
index 04c3ce8e9..b137b07d1 100644
--- a/src/wx/nag_dialog.cc
+++ b/src/wx/nag_dialog.cc
@@ -79,9 +79,6 @@ NagDialog::maybe_nag (wxWindow* parent, Config::Nag nag, wxString message, bool
return false;
}
- auto d = new NagDialog (parent, nag, message, can_cancel);
- int const r = d->ShowModal();
- d->Destroy ();
-
- return r == wxID_CANCEL;
+ NagDialog dialog(parent, nag, message, can_cancel);
+ return dialog.ShowModal() == wxID_CANCEL;
}
diff --git a/src/wx/templates_dialog.cc b/src/wx/templates_dialog.cc
index 3336277b6..145e4f2b9 100644
--- a/src/wx/templates_dialog.cc
+++ b/src/wx/templates_dialog.cc
@@ -130,17 +130,18 @@ TemplatesDialog::rename_clicked ()
li.m_mask = wxLIST_MASK_TEXT;
_list->GetItem (li);
- auto d = new RenameTemplateDialog (this);
- d->set (li.m_text);
- if (d->ShowModal() == wxID_OK) {
- if (!d->get().IsEmpty()) {
- Config::instance()->rename_template (wx_to_std (li.m_text), wx_to_std (d->get ()));
- _list->SetItem (item, 0, d->get());
- } else {
- error_dialog (this, _("Template names must not be empty."));
- }
+ RenameTemplateDialog dialog(this);
+ dialog.set(li.m_text);
+ if (dialog.ShowModal() != wxID_OK) {
+ return;
+ }
+
+ if (!dialog.get().IsEmpty()) {
+ Config::instance()->rename_template(wx_to_std(li.m_text), wx_to_std(dialog.get()));
+ _list->SetItem(item, 0, dialog.get());
+ } else {
+ error_dialog (this, _("Template names must not be empty."));
}
- d->Destroy ();
}
diff --git a/src/wx/text_panel.cc b/src/wx/text_panel.cc
index ba6c07e76..630ca6944 100644
--- a/src/wx/text_panel.cc
+++ b/src/wx/text_panel.cc
@@ -781,11 +781,10 @@ TextPanel::appearance_dialog_clicked ()
auto c = _parent->selected_text ();
DCPOMATIC_ASSERT (c.size() == 1);
- auto d = new SubtitleAppearanceDialog (this, _parent->film(), c.front(), c.front()->text_of_original_type(_original_type));
- if (d->ShowModal () == wxID_OK) {
- d->apply ();
+ SubtitleAppearanceDialog dialog(this, _parent->film(), c.front(), c.front()->text_of_original_type(_original_type));
+ if (dialog.ShowModal() == wxID_OK) {
+ dialog.apply();
}
- d->Destroy ();
}
diff --git a/src/wx/video_panel.cc b/src/wx/video_panel.cc
index e1770efbe..4f7c2db79 100644
--- a/src/wx/video_panel.cc
+++ b/src/wx/video_panel.cc
@@ -541,17 +541,16 @@ VideoPanel::edit_colour_conversion_clicked ()
{
auto vc = _parent->selected_video ();
- auto d = new ContentColourConversionDialog (this, vc.front()->video->yuv ());
- d->set (vc.front()->video->colour_conversion().get_value_or (PresetColourConversion::all().front().conversion));
- if (d->ShowModal() == wxID_OK) {
+ ContentColourConversionDialog dialog(this, vc.front()->video->yuv());
+ dialog.set(vc.front()->video->colour_conversion().get_value_or(PresetColourConversion::all().front().conversion));
+ if (dialog.ShowModal() == wxID_OK) {
for (auto i: vc) {
- i->video->set_colour_conversion (d->get ());
+ i->video->set_colour_conversion(dialog.get());
}
} else {
/* Reset the colour conversion choice */
film_content_changed (VideoContentProperty::COLOUR_CONVERSION);
}
- d->Destroy ();
}
@@ -725,16 +724,17 @@ bool
VideoPanel::scale_custom_edit_clicked ()
{
auto vc = _parent->selected_video().front()->video;
- auto d = new CustomScaleDialog (this, vc->size(), _parent->film()->frame_size(), vc->custom_ratio(), vc->custom_size());
- int const r = d->ShowModal ();
- if (r == wxID_OK) {
- for (auto i: _parent->selected_video()) {
- i->video->set_custom_ratio (d->custom_ratio());
- i->video->set_custom_size (d->custom_size());
- }
+ CustomScaleDialog dialog(this, vc->size(), _parent->film()->frame_size(), vc->custom_ratio(), vc->custom_size());
+ if (dialog.ShowModal() != wxID_OK) {
+ return false;
+ }
+
+ for (auto i: _parent->selected_video()) {
+ i->video->set_custom_ratio(dialog.custom_ratio());
+ i->video->set_custom_size(dialog.custom_size());
}
- d->Destroy ();
- return r == wxID_OK;
+
+ return true;
}