summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-01-14 22:06:05 +0100
committerCarl Hetherington <cth@carlh.net>2023-01-14 22:06:05 +0100
commit4e4968464eeef1956cb82392e1fc3b27a792ab89 (patch)
tree79db245f320df21a075a0fd26de685e02fff6924
parent0ecea9f4d1a772e99f396e47364e68abfbfe9f7f (diff)
Add wx_ptr and use it instead of ScopeGuard in a lot of places.
-rw-r--r--src/tools/dcpomatic.cc124
-rw-r--r--src/tools/dcpomatic_batch.cc13
-rw-r--r--src/tools/dcpomatic_kdm.cc19
-rw-r--r--src/tools/dcpomatic_player.cc10
-rw-r--r--src/wx/config_dialog.cc28
-rw-r--r--src/wx/content_advanced_dialog.cc6
-rw-r--r--src/wx/content_menu.cc5
-rw-r--r--src/wx/content_panel.cc15
-rw-r--r--src/wx/controls.cc7
-rw-r--r--src/wx/editable_list.h8
-rw-r--r--src/wx/fonts_dialog.cc7
-rw-r--r--src/wx/language_tag_widget.cc4
-rw-r--r--src/wx/region_subtag_widget.cc4
-rw-r--r--src/wx/screen_dialog.cc10
-rw-r--r--src/wx/screens_panel.cc13
-rw-r--r--src/wx/text_panel.cc4
-rw-r--r--src/wx/timing_panel.cc4
-rw-r--r--src/wx/wx_ptr.h80
-rw-r--r--src/wx/wx_util.cc11
19 files changed, 195 insertions, 177 deletions
diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc
index 257bb7ab1..546306ac4 100644
--- a/src/tools/dcpomatic.cc
+++ b/src/tools/dcpomatic.cc
@@ -53,6 +53,7 @@
#include "wx/update_dialog.h"
#include "wx/video_waveform_dialog.h"
#include "wx/wx_signal_manager.h"
+#include "wx/wx_ptr.h"
#include "wx/wx_util.h"
#include "lib/analytics.h"
#include "lib/audio_content.h"
@@ -80,7 +81,6 @@
#include "lib/log.h"
#include "lib/make_dcp.h"
#include "lib/release_notes.h"
-#include "lib/scope_guard.h"
#include "lib/screen.h"
#include "lib/send_kdm_email_job.h"
#include "lib/signal_manager.h"
@@ -577,8 +577,7 @@ private:
void file_new ()
{
- auto d = new FilmNameLocationDialog (this, _("New Film"), true);
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<FilmNameLocationDialog>(this, _("New Film"), true);
int const r = d->ShowModal ();
if (r != wxID_OK || !d->check_path() || !maybe_save_then_delete_film<FilmChangedClosingDialog>()) {
@@ -613,13 +612,12 @@ private:
void file_open ()
{
- auto c = new wxDirDialog (
+ auto c = make_wx<wxDirDialog>(
this,
_("Select film to open"),
std_to_wx (Config::instance()->default_directory_or (wx_to_std (wxStandardPaths::Get().GetDocumentsDir())).string ()),
wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST
);
- ScopeGuard sg = [c]() { c->Destroy(); };
int r;
while (true) {
@@ -643,8 +641,7 @@ private:
void file_save_as_template ()
{
- auto d = new SaveTemplateDialog (this);
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<SaveTemplateDialog>(this);
if (d->ShowModal() == wxID_OK) {
Config::instance()->save_template (_film, d->name ());
}
@@ -652,8 +649,7 @@ private:
void file_duplicate ()
{
- auto d = new FilmNameLocationDialog (this, _("Duplicate Film"), false);
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<FilmNameLocationDialog>(this, _("Duplicate Film"), false);
if (d->ShowModal() == wxID_OK && d->check_path() && maybe_save_film<FilmChangedDuplicatingDialog>()) {
shared_ptr<Film> film (new Film (d->path()));
@@ -665,11 +661,10 @@ private:
void file_duplicate_and_open ()
{
- auto d = new FilmNameLocationDialog (this, _("Duplicate Film"), false);
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<FilmNameLocationDialog>(this, _("Duplicate Film"), false);
if (d->ShowModal() == wxID_OK && d->check_path() && maybe_save_film<FilmChangedDuplicatingDialog>()) {
- shared_ptr<Film> film (new Film (d->path()));
+ auto film = make_shared<Film>(d->path());
film->copy_from (_film);
film->set_name (d->path().filename().generic_string());
film->write_metadata ();
@@ -728,8 +723,7 @@ private:
{
DCPOMATIC_ASSERT (_clipboard);
- auto d = new PasteDialog (this, static_cast<bool>(_clipboard->video), static_cast<bool>(_clipboard->audio), !_clipboard->text.empty());
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<PasteDialog>(this, static_cast<bool>(_clipboard->video), static_cast<bool>(_clipboard->audio), !_clipboard->text.empty());
if (d->ShowModal() != wxID_OK) {
return;
}
@@ -771,13 +765,12 @@ private:
void tools_restore_default_preferences ()
{
- auto d = new wxMessageDialog (
- 0,
+ auto d = make_wx<wxMessageDialog>(
+ nullptr,
_("Are you sure you want to restore preferences to their defaults? This cannot be undone."),
_("Restore default preferences"),
wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION
);
- ScopeGuard sg = [d]() { d->Destroy(); };
if (d->ShowModal() == wxID_YES) {
Config::restore_defaults ();
@@ -786,11 +779,10 @@ private:
void tools_export_preferences ()
{
- auto dialog = new wxFileDialog (
+ auto dialog = make_wx<wxFileDialog>(
this, _("Specify ZIP file"), wxEmptyString, wxT("dcpomatic_config.zip"), wxT("ZIP files (*.zip)|*.zip"),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT
);
- ScopeGuard sg = [dialog]() { dialog->Destroy(); };
if (dialog->ShowModal() == wxID_OK) {
save_all_config_as_zip (wx_to_std(dialog->GetPath()));
@@ -816,8 +808,7 @@ private:
}
if (Config::instance()->show_hints_before_make_dcp()) {
- auto hints = new HintsDialog (this, _film, false);
- ScopeGuard sg = [hints]() { hints->Destroy(); };
+ auto hints = make_wx<HintsDialog>(this, _film, false);
if (hints->ShowModal() == wxID_CANCEL) {
return;
}
@@ -929,8 +920,7 @@ private:
}
if (Config::instance()->show_hints_before_make_dcp()) {
- auto hints = new HintsDialog (this, _film, false);
- ScopeGuard sg = [hints]() { hints->Destroy(); };
+ auto hints = make_wx<HintsDialog>(this, _film, false);
if (hints->ShowModal() == wxID_CANCEL) {
return;
}
@@ -968,8 +958,7 @@ private:
return;
}
- auto d = new SelfDKDMDialog (this, _film);
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<SelfDKDMDialog>(this, _film);
if (d->ShowModal () != wxID_OK) {
return;
}
@@ -1025,8 +1014,7 @@ private:
void jobs_export_video_file ()
{
- auto d = new ExportVideoFileDialog (this, _film->isdcf_name(true));
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<ExportVideoFileDialog>(this, _film->isdcf_name(true));
if (d->ShowModal() != wxID_OK) {
return;
}
@@ -1053,8 +1041,7 @@ private:
void jobs_export_subtitles ()
{
- auto d = new ExportSubtitlesDialog (this, _film->reels().size(), _film->interop());
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<ExportSubtitlesDialog>(this, _film->reels().size(), _film->interop());
if (d->ShowModal() != wxID_OK) {
return;
}
@@ -1137,44 +1124,43 @@ private:
void tools_send_translations ()
{
- auto d = new SendI18NDialog (this);
- ScopeGuard sg = [d]() { d->Destroy(); };
- if (d->ShowModal() == wxID_OK) {
- string body;
- body += d->name() + "\n";
- body += d->language() + "\n";
- body += string(dcpomatic_version) + " " + string(dcpomatic_git_commit) + "\n";
- body += "--\n";
- auto translations = I18NHook::translations ();
- for (auto i: translations) {
- body += i.first + "\n" + i.second + "\n\n";
- }
- list<string> to = { "carl@dcpomatic.com" };
- if (d->email().find("@") == string::npos) {
- error_dialog (this, _("You must enter a valid email address when sending translations, "
- "otherwise the DCP-o-matic maintainers cannot credit you or contact you with questions."));
- } else {
- Emailer emailer (d->email(), to, "DCP-o-matic translations", body);
- try {
- emailer.send ("main.carlh.net", 2525, EmailProtocol::STARTTLS);
- } catch (NetworkError& e) {
- error_dialog (this, _("Could not send translations"), std_to_wx(e.what()));
- }
+ auto d = make_wx<SendI18NDialog>(this);
+ if (d->ShowModal() != wxID_OK) {
+ return;
+ }
+
+ string body;
+ body += d->name() + "\n";
+ body += d->language() + "\n";
+ body += string(dcpomatic_version) + " " + string(dcpomatic_git_commit) + "\n";
+ body += "--\n";
+ auto translations = I18NHook::translations ();
+ for (auto i: translations) {
+ body += i.first + "\n" + i.second + "\n\n";
+ }
+ list<string> to = { "carl@dcpomatic.com" };
+ if (d->email().find("@") == string::npos) {
+ error_dialog (this, _("You must enter a valid email address when sending translations, "
+ "otherwise the DCP-o-matic maintainers cannot credit you or contact you with questions."));
+ } else {
+ Emailer emailer (d->email(), to, "DCP-o-matic translations", body);
+ try {
+ emailer.send ("main.carlh.net", 2525, EmailProtocol::STARTTLS);
+ } catch (NetworkError& e) {
+ error_dialog (this, _("Could not send translations"), std_to_wx(e.what()));
}
}
}
void help_about ()
{
- auto d = new AboutDialog (this);
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<AboutDialog>(this);
d->ShowModal ();
}
void help_report_a_problem ()
{
- auto d = new ReportProblemDialog (this, _film);
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<ReportProblemDialog>(this, _film);
if (d->ShowModal () == wxID_OK) {
d->report ();
}
@@ -1186,13 +1172,12 @@ private:
return true;
}
- auto d = new wxMessageDialog (
- 0,
+ auto d = make_wx<wxMessageDialog>(
+ nullptr,
_("There are unfinished jobs; are you sure you want to quit?"),
_("Unfinished jobs"),
wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION
);
- ScopeGuard sg = [d]() { d->Destroy(); };
return d->ShowModal() == wxID_YES;
}
@@ -1529,8 +1514,7 @@ private:
}
if (uc->state() == UpdateChecker::State::YES) {
- auto dialog = new UpdateDialog (this, uc->stable(), uc->test());
- ScopeGuard sg = [dialog]() { dialog->Destroy(); };
+ auto dialog = make_wx<UpdateDialog>(this, uc->stable(), uc->test());
dialog->ShowModal ();
} else if (uc->state() == UpdateChecker::State::FAILED) {
error_dialog (this, _("The DCP-o-matic download server could not be contacted."));
@@ -1567,8 +1551,7 @@ private:
void analytics_message (string title, string html)
{
- auto d = new HTMLDialog(this, std_to_wx(title), std_to_wx(html));
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<HTMLDialog>(this, std_to_wx(title), std_to_wx(html));
d->ShowModal();
}
@@ -1738,8 +1721,7 @@ private:
auto release_notes = find_release_notes(gui_is_dark());
if (release_notes) {
- auto notes = new HTMLDialog(nullptr, _("Release notes"), std_to_wx(*release_notes), true);
- ScopeGuard sg = [notes]() { notes->Destroy(); };
+ auto notes = make_wx<HTMLDialog>(nullptr, _("Release notes"), std_to_wx(*release_notes), true);
notes->Centre();
notes->ShowModal();
}
@@ -1892,7 +1874,7 @@ private:
if (config->nagged(Config::NAG_BAD_SIGNER_CHAIN_UTF8)) {
return false;
}
- auto d = new RecreateChainDialog (
+ auto d = make_wx<RecreateChainDialog>(
_frame, _("Recreate signing certificates"),
_("The certificate chain that DCP-o-matic uses for signing DCPs and KDMs contains a small error\n"
"which will prevent DCPs from being validated correctly on some systems. Do you want to re-create\n"
@@ -1900,7 +1882,6 @@ private:
_("Do nothing"),
Config::NAG_BAD_SIGNER_CHAIN_UTF8
);
- ScopeGuard sg = [d]() { d->Destroy(); };
return d->ShowModal() == wxID_OK;
}
case Config::BAD_SIGNER_VALIDITY_TOO_LONG:
@@ -1908,7 +1889,7 @@ private:
if (config->nagged(Config::NAG_BAD_SIGNER_CHAIN_VALIDITY)) {
return false;
}
- auto d = new RecreateChainDialog (
+ auto d = make_wx<RecreateChainDialog>(
_frame, _("Recreate signing certificates"),
_("The certificate chain that DCP-o-matic uses for signing DCPs and KDMs has a validity period\n"
"that is too long. This will cause problems playing back DCPs on some systems.\n"
@@ -1916,19 +1897,17 @@ private:
_("Do nothing"),
Config::NAG_BAD_SIGNER_CHAIN_VALIDITY
);
- ScopeGuard sg = [d]() { d->Destroy(); };
return d->ShowModal() == wxID_OK;
}
case Config::BAD_SIGNER_INCONSISTENT:
{
- auto d = new RecreateChainDialog (
+ auto d = make_wx<RecreateChainDialog>(
_frame, _("Recreate signing certificates"),
_("The certificate chain that DCP-o-matic uses for signing DCPs and KDMs is inconsistent and\n"
"cannot be used. DCP-o-matic cannot start unless you re-create it. Do you want to re-create\n"
"the certificate chain for signing DCPs and KDMs?"),
_("Close DCP-o-matic")
);
- ScopeGuard sg = [d]() { d->Destroy(); };
if (d->ShowModal() != wxID_OK) {
exit (EXIT_FAILURE);
}
@@ -1936,7 +1915,7 @@ private:
}
case Config::BAD_DECRYPTION_INCONSISTENT:
{
- auto d = new RecreateChainDialog (
+ auto d = make_wx<RecreateChainDialog>(
_frame, _("Recreate KDM decryption chain"),
_("The certificate chain that DCP-o-matic uses for decrypting KDMs is inconsistent and\n"
"cannot be used. DCP-o-matic cannot start unless you re-create it. Do you want to re-create\n"
@@ -1944,7 +1923,6 @@ private:
"configuration before continuing."),
_("Close DCP-o-matic")
);
- ScopeGuard sg = [d]() { d->Destroy(); };
if (d->ShowModal() != wxID_OK) {
exit (EXIT_FAILURE);
}
diff --git a/src/tools/dcpomatic_batch.cc b/src/tools/dcpomatic_batch.cc
index 64015a0e3..b73d0a418 100644
--- a/src/tools/dcpomatic_batch.cc
+++ b/src/tools/dcpomatic_batch.cc
@@ -24,6 +24,7 @@
#include "wx/full_config_dialog.h"
#include "wx/job_manager_view.h"
#include "wx/servers_list_dialog.h"
+#include "wx/wx_ptr.h"
#include "wx/wx_signal_manager.h"
#include "wx/wx_util.h"
#include "lib/compose.hpp"
@@ -33,7 +34,6 @@
#include "lib/job.h"
#include "lib/job_manager.h"
#include "lib/make_dcp.h"
-#include "lib/scope_guard.h"
#include "lib/transcode_job.h"
#include "lib/util.h"
#include "lib/version.h"
@@ -269,13 +269,12 @@ private:
return true;
}
- auto d = new wxMessageDialog (
- 0,
+ auto d = make_wx<wxMessageDialog>(
+ nullptr,
_("There are unfinished jobs; are you sure you want to quit?"),
_("Unfinished jobs"),
wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION
);
- ScopeGuard sg = [d]{ d->Destroy(); };
return d->ShowModal() == wxID_YES;
}
@@ -321,15 +320,13 @@ private:
void help_about ()
{
- auto d = new AboutDialog (this);
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<AboutDialog>(this);
d->ShowModal ();
}
void add_film ()
{
- auto dialog = new wxDirDialog(this, _("Select film to open"), wxStandardPaths::Get().GetDocumentsDir(), wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST);
- ScopeGuard sg = [dialog]() { dialog->Destroy(); };
+ auto dialog = make_wx<wxDirDialog>(this, _("Select film to open"), wxStandardPaths::Get().GetDocumentsDir(), wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST);
if (_last_parent) {
dialog->SetPath(std_to_wx(_last_parent.get().string()));
}
diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc
index 256367977..87a77c626 100644
--- a/src/tools/dcpomatic_kdm.cc
+++ b/src/tools/dcpomatic_kdm.cc
@@ -33,6 +33,7 @@
#include "wx/report_problem_dialog.h"
#include "wx/screens_panel.h"
#include "wx/static_text.h"
+#include "wx/wx_ptr.h"
#include "wx/wx_signal_manager.h"
#include "wx/wx_util.h"
#include "lib/cinema.h"
@@ -47,7 +48,6 @@
#include "lib/file_log.h"
#include "lib/job_manager.h"
#include "lib/kdm_with_metadata.h"
-#include "lib/scope_guard.h"
#include "lib/screen.h"
#include "lib/send_kdm_email_job.h"
#include <dcp/encrypted_kdm.h>
@@ -266,15 +266,13 @@ private:
void help_about ()
{
- auto d = new AboutDialog (this);
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<AboutDialog>(this);
d->ShowModal ();
}
void help_report_a_problem ()
{
- auto d = new ReportProblemDialog (this, shared_ptr<Film>());
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<ReportProblemDialog>(this, shared_ptr<Film>());
if (d->ShowModal () == wxID_OK) {
d->report ();
}
@@ -512,10 +510,7 @@ private:
void add_dkdm_clicked ()
{
- auto dialog = new FileDialog(this, _("Select DKDM file"), wxT("XML files|*.xml|All files|*.*"), wxFD_MULTIPLE, "AddDKDMPath");
-
- ScopeGuard sg = [dialog]() { dialog->Destroy(); };
-
+ auto dialog = make_wx<FileDialog>(this, _("Select DKDM file"), wxT("XML files|*.xml|All files|*.*"), wxFD_MULTIPLE, "AddDKDMPath");
if (!dialog->show()) {
return;
}
@@ -566,8 +561,7 @@ private:
void add_dkdm_folder_clicked ()
{
- auto d = new NewDKDMFolderDialog (this);
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<NewDKDMFolderDialog>(this);
if (d->ShowModal() != wxID_OK) {
return;
}
@@ -718,11 +712,10 @@ private:
return;
}
- auto d = new wxFileDialog (
+ auto d = make_wx<wxFileDialog>(
this, _("Select DKDM File"), wxEmptyString, wxEmptyString, wxT("XML files (*.xml)|*.xml"),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT
);
- ScopeGuard sg = [d]() { d->Destroy(); };
if (d->ShowModal() == wxID_OK) {
dkdm->dkdm().as_xml(wx_to_std(d->GetPath()));
diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc
index 1b2b98729..600d1c6b4 100644
--- a/src/tools/dcpomatic_player.cc
+++ b/src/tools/dcpomatic_player.cc
@@ -32,6 +32,7 @@
#include "wx/update_dialog.h"
#include "wx/verify_dcp_dialog.h"
#include "wx/verify_dcp_progress_dialog.h"
+#include "wx/wx_ptr.h"
#include "wx/wx_signal_manager.h"
#include "wx/wx_util.h"
#include "lib/compose.hpp"
@@ -617,8 +618,7 @@ private:
d = std_to_wx (Config::instance()->last_player_load_directory()->string());
}
- auto c = new wxDirDialog (this, _("Select DCP to open"), d, wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST);
- ScopeGuard sg = [c]() { c->Destroy(); };
+ auto c = make_wx<wxDirDialog>(this, _("Select DCP to open"), d, wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST);
int r;
while (true) {
@@ -644,13 +644,12 @@ private:
initial_dir = std_to_wx(Config::instance()->last_player_load_directory()->string());
}
- auto c = new wxDirDialog (
+ auto c = make_wx<wxDirDialog>(
this,
_("Select DCP to open as OV"),
initial_dir,
wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST
);
- ScopeGuard sg = [c]() { c->Destroy(); };
int r;
while (true) {
@@ -688,8 +687,7 @@ private:
void file_add_kdm ()
{
- auto d = new wxFileDialog (this, _("Select KDM"));
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<wxFileDialog>(this, _("Select KDM"));
if (d->ShowModal() == wxID_OK) {
DCPOMATIC_ASSERT (_film);
diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc
index bf7e295ee..51b6ff2e9 100644
--- a/src/wx/config_dialog.cc
+++ b/src/wx/config_dialog.cc
@@ -25,6 +25,7 @@
#include "dcpomatic_button.h"
#include "nag_dialog.h"
#include "static_text.h"
+#include "wx_ptr.h"
#include "lib/constants.h"
#include <dcp/file.h>
#include <dcp/raw_convert.h>
@@ -367,8 +368,7 @@ CertificateChainEditor::add_button (wxWindow* button)
void
CertificateChainEditor::add_certificate ()
{
- auto d = new wxFileDialog (this, _("Select Certificate File"));
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<wxFileDialog>(this, _("Select Certificate File"));
if (d->ShowModal() == wxID_OK) {
try {
@@ -450,11 +450,10 @@ CertificateChainEditor::export_certificate ()
default_name = "intermediate.pem";
}
- auto d = new wxFileDialog(
+ auto d = make_wx<wxFileDialog>(
this, _("Select Certificate File"), wxEmptyString, default_name, wxT ("PEM files (*.pem)|*.pem"),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT
);
- ScopeGuard sg = [d]() { d->Destroy(); };
auto j = all.begin ();
for (int k = 0; k < i; ++k) {
@@ -481,11 +480,10 @@ CertificateChainEditor::export_certificate ()
void
CertificateChainEditor::export_chain ()
{
- auto d = new wxFileDialog (
+ auto d = make_wx<wxFileDialog>(
this, _("Select Chain File"), wxEmptyString, wxT("certificate_chain.pem"), wxT("PEM files (*.pem)|*.pem"),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT
);
- ScopeGuard sg = [d]() { d->Destroy(); };
if (d->ShowModal() != wxID_OK) {
return;
@@ -546,8 +544,7 @@ CertificateChainEditor::remake_certificates ()
return;
}
- auto d = new MakeChainDialog (this, _get());
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<MakeChainDialog>(this, _get());
if (d->ShowModal () == wxID_OK) {
_set (d->get());
@@ -574,8 +571,7 @@ CertificateChainEditor::update_private_key ()
void
CertificateChainEditor::import_private_key ()
{
- auto d = new wxFileDialog (this, _("Select Key File"));
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<wxFileDialog>(this, _("Select Key File"));
if (d->ShowModal() == wxID_OK) {
try {
@@ -608,11 +604,10 @@ CertificateChainEditor::export_private_key ()
return;
}
- auto d = new wxFileDialog (
+ auto d = make_wx<wxFileDialog>(
this, _("Select Key File"), wxEmptyString, wxT("private_key.pem"), wxT("PEM files (*.pem)|*.pem"),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT
);
- ScopeGuard sg = [d]() { d->Destroy(); };
if (d->ShowModal () == wxID_OK) {
boost::filesystem::path path (wx_to_std(d->GetPath()));
@@ -727,11 +722,10 @@ KeysPage::signing_advanced ()
void
KeysPage::export_decryption_chain_and_key ()
{
- auto d = new wxFileDialog (
+ auto d = make_wx<wxFileDialog>(
_panel, _("Select Export File"), wxEmptyString, wxEmptyString, wxT ("DOM files (*.dom)|*.dom"),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT
);
- ScopeGuard sg = [d]() { d->Destroy(); };
if (d->ShowModal() != wxID_OK) {
return;
@@ -762,10 +756,9 @@ KeysPage::import_decryption_chain_and_key ()
return;
}
- auto d = new wxFileDialog (
+ auto d = make_wx<wxFileDialog>(
_panel, _("Select File To Import"), wxEmptyString, wxEmptyString, wxT ("DOM files (*.dom)|*.dom")
);
- ScopeGuard sg = [d]() { d->Destroy(); };
if (d->ShowModal() != wxID_OK) {
return;
@@ -825,11 +818,10 @@ KeysPage::export_decryption_certificate ()
}
default_name += wxT("_kdm_decryption_cert.pem");
- auto d = new wxFileDialog (
+ auto d = make_wx<wxFileDialog>(
_panel, _("Select Certificate File"), wxEmptyString, default_name, wxT("PEM files (*.pem)|*.pem"),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT
);
- ScopeGuard sg = [d]() { d->Destroy(); };
if (d->ShowModal() != wxID_OK) {
return;
diff --git a/src/wx/content_advanced_dialog.cc b/src/wx/content_advanced_dialog.cc
index 35343d78d..752fa565a 100644
--- a/src/wx/content_advanced_dialog.cc
+++ b/src/wx/content_advanced_dialog.cc
@@ -25,13 +25,13 @@
#include "filter_dialog.h"
#include "language_tag_widget.h"
#include "static_text.h"
+#include "wx_ptr.h"
#include "wx_util.h"
#include "lib/content.h"
#include "lib/dcp_content.h"
#include "lib/filter.h"
#include "lib/ffmpeg_content.h"
#include "lib/image_content.h"
-#include "lib/scope_guard.h"
#include "lib/video_content.h"
#include <dcp/warnings.h>
LIBDCP_DISABLE_WARNINGS
@@ -181,9 +181,7 @@ ContentAdvancedDialog::edit_filters ()
return;
}
- auto dialog = new FilterDialog(this, _filters_list);
- ScopeGuard sg = [dialog]() { dialog->Destroy(); };
-
+ auto dialog = make_wx<FilterDialog>(this, _filters_list);
dialog->ActiveChanged.connect(bind(&ContentAdvancedDialog::filters_changed, this, _1));
dialog->ShowModal();
}
diff --git a/src/wx/content_menu.cc b/src/wx/content_menu.cc
index 80976e5f6..5957ac06d 100644
--- a/src/wx/content_menu.cc
+++ b/src/wx/content_menu.cc
@@ -27,6 +27,7 @@
#include "repeat_dialog.h"
#include "timeline_video_content_view.h"
#include "timeline_audio_content_view.h"
+#include "wx_ptr.h"
#include "wx_util.h"
#include "lib/audio_content.h"
#include "lib/config.h"
@@ -44,7 +45,6 @@
#include "lib/image_content.h"
#include "lib/job_manager.h"
#include "lib/playlist.h"
-#include "lib/scope_guard.h"
#include "lib/video_content.h"
#include <dcp/cpl.h>
#include <dcp/decrypted_kdm.h>
@@ -466,8 +466,7 @@ ContentMenu::advanced ()
DCPOMATIC_ASSERT(!_content.empty());
auto content = _content.front();
- auto dialog = new ContentAdvancedDialog(_parent, content);
- ScopeGuard sg = [dialog]() { dialog->Destroy(); };
+ auto dialog = make_wx<ContentAdvancedDialog>(_parent, content);
if (dialog->ShowModal() == wxID_CANCEL) {
return;
diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc
index a25e37a2a..71f32068a 100644
--- a/src/wx/content_panel.cc
+++ b/src/wx/content_panel.cc
@@ -30,6 +30,7 @@
#include "timeline_dialog.h"
#include "timing_panel.h"
#include "video_panel.h"
+#include "wx_ptr.h"
#include "wx_util.h"
#include "lib/audio_content.h"
#include "lib/case_insensitive_sorter.h"
@@ -45,7 +46,6 @@
#include "lib/image_content.h"
#include "lib/log.h"
#include "lib/playlist.h"
-#include "lib/scope_guard.h"
#include "lib/string_text_file.h"
#include "lib/string_text_file_content.h"
#include "lib/text_content.h"
@@ -595,7 +595,7 @@ ContentPanel::add_file_clicked ()
/* The wxFD_CHANGE_DIR here prevents a `could not set working directory' error 123 on Windows when using
non-Latin filenames or paths.
*/
- auto dialog = new FileDialog(
+ auto dialog = make_wx<FileDialog>(
_splitter,
_("Choose a file or files"),
wxT("All files|*.*|Subtitle files|*.srt;*.xml|Audio files|*.wav;*.w64;*.flac;*.aif;*.aiff"),
@@ -604,8 +604,6 @@ ContentPanel::add_file_clicked ()
add_files_override_path()
);
- ScopeGuard sg = [dialog]() { dialog->Destroy(); };
-
if (dialog->show()) {
add_files(dialog->paths());
}
@@ -615,8 +613,7 @@ ContentPanel::add_file_clicked ()
void
ContentPanel::add_folder_clicked ()
{
- auto d = new DirDialog(_splitter, _("Choose a folder"), wxDD_DIR_MUST_EXIST, "AddFilesPath", add_files_override_path());
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<DirDialog>(_splitter, _("Choose a folder"), wxDD_DIR_MUST_EXIST, "AddFilesPath", add_files_override_path());
if (d->show()) {
add_folder(d->path());
}
@@ -643,8 +640,7 @@ ContentPanel::add_folder(boost::filesystem::path folder)
for (auto i: content) {
auto ic = dynamic_pointer_cast<ImageContent> (i);
if (ic) {
- auto e = new ImageSequenceDialog (_splitter);
- ScopeGuard sg = [e]() { e->Destroy(); };
+ auto e = make_wx<ImageSequenceDialog>(_splitter);
if (e->ShowModal() != wxID_OK) {
return;
@@ -660,8 +656,7 @@ ContentPanel::add_folder(boost::filesystem::path folder)
void
ContentPanel::add_dcp_clicked ()
{
- auto d = new DirDialog(_splitter, _("Choose a DCP folder"), wxDD_DIR_MUST_EXIST, "AddFilesPath", add_files_override_path());
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<DirDialog>(_splitter, _("Choose a DCP folder"), wxDD_DIR_MUST_EXIST, "AddFilesPath", add_files_override_path());
if (d->show()) {
add_dcp(d->path());
}
diff --git a/src/wx/controls.cc b/src/wx/controls.cc
index 804b59dae..b9eebade5 100644
--- a/src/wx/controls.cc
+++ b/src/wx/controls.cc
@@ -28,6 +28,7 @@
#include "playhead_to_frame_dialog.h"
#include "playhead_to_timecode_dialog.h"
#include "static_text.h"
+#include "wx_ptr.h"
#include "wx_util.h"
#include "lib/content_factory.h"
#include "lib/cross.h"
@@ -381,8 +382,7 @@ Controls::setup_sensitivity ()
void
Controls::timecode_clicked ()
{
- auto dialog = new PlayheadToTimecodeDialog(this, _viewer.position(), _film->video_frame_rate());
- ScopeGuard sg = [dialog]() { dialog->Destroy(); };
+ auto dialog = make_wx<PlayheadToTimecodeDialog>(this, _viewer.position(), _film->video_frame_rate());
if (dialog->ShowModal() == wxID_OK) {
_viewer.seek(dialog->get(), true);
@@ -393,8 +393,7 @@ Controls::timecode_clicked ()
void
Controls::frame_number_clicked ()
{
- auto dialog = new PlayheadToFrameDialog(this, _viewer.position(), _film->video_frame_rate());
- ScopeGuard sg = [dialog]() { dialog->Destroy(); };
+ auto dialog = make_wx<PlayheadToFrameDialog>(this, _viewer.position(), _film->video_frame_rate());
if (dialog->ShowModal() == wxID_OK) {
_viewer.seek(dialog->get(), true);
diff --git a/src/wx/editable_list.h b/src/wx/editable_list.h
index f3a0dd957..f8050cac5 100644
--- a/src/wx/editable_list.h
+++ b/src/wx/editable_list.h
@@ -24,8 +24,8 @@
#include "dcpomatic_button.h"
+#include "wx_ptr.h"
#include "wx_util.h"
-#include "lib/scope_guard.h"
#include <dcp/warnings.h>
LIBDCP_DISABLE_WARNINGS
#include <wx/listctrl.h>
@@ -233,8 +233,7 @@ private:
void add_clicked ()
{
- S* dialog = new S (this);
- ScopeGuard sg = [dialog]() { dialog->Destroy(); };
+ auto dialog = make_wx<S>(this);
if (dialog->ShowModal() == wxID_OK) {
auto const v = dialog->get ();
@@ -258,8 +257,7 @@ private:
std::vector<T> all = _get ();
DCPOMATIC_ASSERT (item >= 0 && item < int (all.size ()));
- S* dialog = new S (this);
- ScopeGuard sg = [dialog]() { dialog->Destroy(); };
+ auto dialog = make_wx<S>(this);
dialog->set (all[item]);
if (dialog->ShowModal() == wxID_OK) {
auto const v = dialog->get ();
diff --git a/src/wx/fonts_dialog.cc b/src/wx/fonts_dialog.cc
index b21bb8498..9e38e9e68 100644
--- a/src/wx/fonts_dialog.cc
+++ b/src/wx/fonts_dialog.cc
@@ -22,6 +22,7 @@
#include "dcpomatic_button.h"
#include "fonts_dialog.h"
#include "system_font_dialog.h"
+#include "wx_ptr.h"
#include "wx_util.h"
#include "lib/content.h"
#include "lib/font.h"
@@ -184,8 +185,7 @@ FontsDialog::set_from_file_clicked ()
default_dir = "/System/Library/Fonts";
#endif
- auto d = new wxFileDialog (this, _("Choose a font file"), default_dir, wxT(""), wxT("*.ttf;*.otf;*.ttc"), wxFD_CHANGE_DIR);
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<wxFileDialog>(this, _("Choose a font file"), default_dir, wxT(""), wxT("*.ttf;*.otf;*.ttc"), wxFD_CHANGE_DIR);
if (d->ShowModal() != wxID_OK) {
return;
@@ -204,8 +204,7 @@ FontsDialog::set_from_system_font_clicked()
return;
}
- auto dialog = new SystemFontDialog(this);
- ScopeGuard sg = [dialog]() { dialog->Destroy(); };
+ auto dialog = make_wx<SystemFontDialog>(this);
if (dialog->ShowModal() == wxID_OK) {
auto font_file = dialog->get_font();
if (font_file) {
diff --git a/src/wx/language_tag_widget.cc b/src/wx/language_tag_widget.cc
index f28046bd9..d14c43f0c 100644
--- a/src/wx/language_tag_widget.cc
+++ b/src/wx/language_tag_widget.cc
@@ -22,6 +22,7 @@
#include "dcpomatic_button.h"
#include "language_tag_dialog.h"
#include "language_tag_widget.h"
+#include "wx_ptr.h"
#include "wx_util.h"
#include "lib/scope_guard.h"
#include <dcp/warnings.h>
@@ -66,8 +67,7 @@ LanguageTagWidget::~LanguageTagWidget ()
void
LanguageTagWidget::edit ()
{
- auto d = new LanguageTagDialog(_parent, _tag.get_value_or(dcp::LanguageTag("en")));
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<LanguageTagDialog>(_parent, _tag.get_value_or(dcp::LanguageTag("en")));
if (d->ShowModal() == wxID_OK) {
set(d->get());
Changed(d->get());
diff --git a/src/wx/region_subtag_widget.cc b/src/wx/region_subtag_widget.cc
index 3b0457f13..54c6d9d43 100644
--- a/src/wx/region_subtag_widget.cc
+++ b/src/wx/region_subtag_widget.cc
@@ -23,6 +23,7 @@
#include "full_language_tag_dialog.h"
#include "region_subtag_dialog.h"
#include "region_subtag_widget.h"
+#include "wx_ptr.h"
#include "wx_util.h"
#include "lib/scope_guard.h"
#include <dcp/warnings.h>
@@ -67,8 +68,7 @@ RegionSubtagWidget::~RegionSubtagWidget()
void
RegionSubtagWidget::edit()
{
- auto d = new RegionSubtagDialog(_parent, _tag.get_value_or(dcp::LanguageTag::RegionSubtag("US")));
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<RegionSubtagDialog>(_parent, _tag.get_value_or(dcp::LanguageTag::RegionSubtag("US")));
if (d->ShowModal() == wxID_OK) {
set(d->get());
diff --git a/src/wx/screen_dialog.cc b/src/wx/screen_dialog.cc
index 6d7fb4f03..3fa17353d 100644
--- a/src/wx/screen_dialog.cc
+++ b/src/wx/screen_dialog.cc
@@ -25,6 +25,7 @@
#include "screen_dialog.h"
#include "static_text.h"
#include "table_dialog.h"
+#include "wx_ptr.h"
#include "wx_util.h"
#include "lib/compose.hpp"
#include "lib/scope_guard.h"
@@ -64,8 +65,7 @@ public:
void load_certificate ()
{
- auto dialog = new FileDialog(this, _("Trusted Device certificate"), wxEmptyString, wxFD_DEFAULT_STYLE, "SelectCertificatePath");
- ScopeGuard sg = [dialog]() { dialog->Destroy(); };
+ auto dialog = make_wx<FileDialog>(this, _("Trusted Device certificate"), wxEmptyString, wxFD_DEFAULT_STYLE, "SelectCertificatePath");
if (!dialog->show()) {
return;
}
@@ -259,8 +259,7 @@ ScreenDialog::load_recipient (boost::filesystem::path file)
void
ScreenDialog::get_recipient_from_file ()
{
- auto dialog = new FileDialog(this, _("Select Certificate File"), wxEmptyString, wxFD_DEFAULT_STYLE , "SelectCertificatePath");
- ScopeGuard sg = [dialog]() { dialog->Destroy(); };
+ auto dialog = make_wx<FileDialog>(this, _("Select Certificate File"), wxEmptyString, wxFD_DEFAULT_STYLE , "SelectCertificatePath");
if (dialog->show()) {
load_recipient(dialog->paths()[0]);
}
@@ -272,8 +271,7 @@ ScreenDialog::get_recipient_from_file ()
void
ScreenDialog::download_recipient ()
{
- auto dialog = new DownloadCertificateDialog (this);
- ScopeGuard sg = [dialog]() { dialog->Destroy(); };
+ auto dialog = make_wx<DownloadCertificateDialog>(this);
if (dialog->ShowModal() == wxID_OK) {
set_recipient(dialog->certificate());
checked_set(_recipient_file, dialog->url());
diff --git a/src/wx/screens_panel.cc b/src/wx/screens_panel.cc
index 1d94d1acb..ad000d988 100644
--- a/src/wx/screens_panel.cc
+++ b/src/wx/screens_panel.cc
@@ -23,6 +23,7 @@
#include "dcpomatic_button.h"
#include "screen_dialog.h"
#include "screens_panel.h"
+#include "wx_ptr.h"
#include "wx_util.h"
#include "lib/cinema.h"
#include "lib/config.h"
@@ -230,8 +231,7 @@ ScreensPanel::add_screen (shared_ptr<Cinema> cinema, shared_ptr<Screen> screen)
void
ScreensPanel::add_cinema_clicked ()
{
- auto dialog = new CinemaDialog (GetParent(), _("Add Cinema"));
- ScopeGuard sg = [dialog]() { dialog->Destroy(); };
+ auto dialog = make_wx<CinemaDialog>(GetParent(), _("Add Cinema"));
if (dialog->ShowModal() == wxID_OK) {
auto cinema = make_shared<Cinema>(dialog->name(), dialog->emails(), dialog->notes(), dialog->utc_offset_hour(), dialog->utc_offset_minute());
@@ -298,10 +298,9 @@ ScreensPanel::edit_cinema_clicked ()
return;
}
- auto dialog = new CinemaDialog(
+ auto dialog = make_wx<CinemaDialog>(
GetParent(), _("Edit cinema"), cinema->name, cinema->emails, cinema->notes, cinema->utc_offset_hour(), cinema->utc_offset_minute()
);
- ScopeGuard sg = [dialog]() { dialog->Destroy(); };
if (dialog->ShowModal() == wxID_OK) {
cinema->name = dialog->name();
@@ -351,8 +350,7 @@ ScreensPanel::add_screen_clicked ()
return;
}
- auto dialog = new ScreenDialog(GetParent(), _("Add Screen"));
- ScopeGuard sg = [dialog]() { dialog->Destroy(); };
+ auto dialog = make_wx<ScreenDialog>(GetParent(), _("Add Screen"));
if (dialog->ShowModal () != wxID_OK) {
return;
@@ -391,7 +389,7 @@ ScreensPanel::edit_screen_clicked ()
auto edit_screen = _selected_screens[0];
- auto dialog = new ScreenDialog(
+ auto dialog = make_wx<ScreenDialog>(
GetParent(), _("Edit screen"),
edit_screen->name,
edit_screen->notes,
@@ -399,7 +397,6 @@ ScreensPanel::edit_screen_clicked ()
edit_screen->recipient_file,
edit_screen->trusted_devices
);
- ScopeGuard sg = [dialog]() { dialog->Destroy(); };
if (dialog->ShowModal() != wxID_OK) {
return;
diff --git a/src/wx/text_panel.cc b/src/wx/text_panel.cc
index 8e7d4434e..94ec8506d 100644
--- a/src/wx/text_panel.cc
+++ b/src/wx/text_panel.cc
@@ -32,6 +32,7 @@
#include "subtitle_appearance_dialog.h"
#include "text_panel.h"
#include "text_view.h"
+#include "wx_ptr.h"
#include "wx_util.h"
#include "lib/analyse_subtitles_job.h"
#include "lib/dcp_content.h"
@@ -370,8 +371,7 @@ TextPanel::dcp_track_changed ()
optional<DCPTextTrack> track;
if (_dcp_track->GetSelection() == int(_dcp_track->GetCount()) - 1) {
- auto d = new DCPTextTrackDialog (this);
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<DCPTextTrackDialog>(this);
if (d->ShowModal() == wxID_OK) {
track = d->get();
}
diff --git a/src/wx/timing_panel.cc b/src/wx/timing_panel.cc
index 732cd07d5..47019487f 100644
--- a/src/wx/timing_panel.cc
+++ b/src/wx/timing_panel.cc
@@ -26,6 +26,7 @@
#include "static_text.h"
#include "timecode.h"
#include "timing_panel.h"
+#include "wx_ptr.h"
#include "wx_util.h"
#include "lib/audio_content.h"
#include "lib/content.h"
@@ -507,8 +508,7 @@ TimingPanel::move_to_start_of_reel_clicked ()
}
}
- auto d = new MoveToDialog(this, position, _parent->film());
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<MoveToDialog>(this, position, _parent->film());
if (d->ShowModal() == wxID_OK) {
for (auto i: _parent->selected()) {
diff --git a/src/wx/wx_ptr.h b/src/wx/wx_ptr.h
new file mode 100644
index 000000000..de18846cc
--- /dev/null
+++ b/src/wx/wx_ptr.h
@@ -0,0 +1,80 @@
+/*
+ Copyright (C) 2023 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#ifndef DCPOMATIC_WX_PTR_H
+#define DCPOMATIC_WX_PTR_H
+
+
+#include <utility>
+
+
+template <class T>
+class wx_ptr
+{
+public:
+ explicit wx_ptr(T* wx)
+ : _wx(wx)
+ {}
+
+ wx_ptr(wx_ptr&) = delete;
+ wx_ptr& operator=(wx_ptr&) = delete;
+
+ wx_ptr(wx_ptr&& other)
+ {
+ _wx = other._wx;
+ other._wx = nullptr;
+ }
+
+ wx_ptr& operator=(wx_ptr&& other)
+ {
+ if (this != &other) {
+ _wx = other._wx;
+ other._wx = nullptr;
+ }
+ return *this;
+ }
+
+ ~wx_ptr()
+ {
+ if (_wx) {
+ _wx->Destroy();
+ }
+ }
+
+ T* operator->() {
+ return _wx;
+ }
+
+private:
+ T* _wx;
+};
+
+
+
+template <class T, typename... Args>
+wx_ptr<T>
+make_wx(Args... args)
+{
+ return wx_ptr<T>(new T(std::forward<Args>(args)...));
+}
+
+
+#endif
diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc
index 1f2afb4f5..d264f8b20 100644
--- a/src/wx/wx_util.cc
+++ b/src/wx/wx_util.cc
@@ -29,12 +29,12 @@
#include "password_entry.h"
#include "region_subtag_widget.h"
#include "static_text.h"
+#include "wx_ptr.h"
#include "wx_util.h"
#include "lib/config.h"
#include "lib/cross.h"
#include "lib/job.h"
#include "lib/job_manager.h"
-#include "lib/scope_guard.h"
#include "lib/util.h"
#include "lib/version.h"
#include <dcp/locale_convert.h>
@@ -161,8 +161,7 @@ add_label_to_sizer (wxGridBagSizer* s, wxStaticText* t, bool, wxGBPosition pos,
void
error_dialog (wxWindow* parent, wxString m, optional<wxString> e)
{
- auto d = new wxMessageDialog (parent, m, _("DCP-o-matic"), wxOK | wxICON_ERROR);
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<wxMessageDialog>(parent, m, _("DCP-o-matic"), wxOK | wxICON_ERROR);
if (e) {
wxString em = *e;
em[0] = wxToupper (em[0]);
@@ -179,8 +178,7 @@ error_dialog (wxWindow* parent, wxString m, optional<wxString> e)
void
message_dialog (wxWindow* parent, wxString m)
{
- auto d = new wxMessageDialog (parent, m, _("DCP-o-matic"), wxOK | wxICON_INFORMATION);
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<wxMessageDialog>(parent, m, _("DCP-o-matic"), wxOK | wxICON_INFORMATION);
d->ShowModal ();
}
@@ -189,8 +187,7 @@ message_dialog (wxWindow* parent, wxString m)
bool
confirm_dialog (wxWindow* parent, wxString m)
{
- auto d = new wxMessageDialog (parent, m, _("DCP-o-matic"), wxYES_NO | wxICON_QUESTION);
- ScopeGuard sg = [d]() { d->Destroy(); };
+ auto d = make_wx<wxMessageDialog>(parent, m, _("DCP-o-matic"), wxYES_NO | wxICON_QUESTION);
return d->ShowModal() == wxID_YES;
}