summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-01-16 01:14:37 +0100
committerCarl Hetherington <cth@carlh.net>2023-01-16 01:15:50 +0100
commitfe851f2e6e57d3a8781ecc173089c19632c521e3 (patch)
treefd0f388d9ce9eccb4a8011361bd166d192918bd8 /src/tools
parente8748f158249d7be906f6c6cf2411df45dd07a24 (diff)
Use wx_ptr more.
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/dcpomatic.cc55
-rw-r--r--src/tools/dcpomatic_disk.cc20
-rw-r--r--src/tools/dcpomatic_playlist.cc3
3 files changed, 21 insertions, 57 deletions
diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc
index af4576fd5..4ac804cc9 100644
--- a/src/tools/dcpomatic.cc
+++ b/src/tools/dcpomatic.cc
@@ -145,7 +145,7 @@ class FilmChangedClosingDialog
public:
explicit FilmChangedClosingDialog (string name)
{
- _dialog = new wxMessageDialog (
+ _dialog.reset(
nullptr,
wxString::Format(_("Save changes to film \"%s\" before closing?"), std_to_wx (name).data()),
/// TRANSLATORS: this is the heading for a dialog box, which tells the user that the current
@@ -159,21 +159,13 @@ public:
);
}
- ~FilmChangedClosingDialog ()
- {
- _dialog->Destroy ();
- }
-
- FilmChangedClosingDialog (FilmChangedClosingDialog const&) = delete;
- FilmChangedClosingDialog& operator= (FilmChangedClosingDialog const&) = delete;
-
int run ()
{
return _dialog->ShowModal ();
}
private:
- wxMessageDialog* _dialog;
+ wx_ptr<wxMessageDialog> _dialog;
};
@@ -182,7 +174,7 @@ class FilmChangedDuplicatingDialog
public:
explicit FilmChangedDuplicatingDialog (string name)
{
- _dialog = new wxMessageDialog (
+ _dialog.reset(
nullptr,
wxString::Format(_("Save changes to film \"%s\" before duplicating?"), std_to_wx (name).data()),
/// TRANSLATORS: this is the heading for a dialog box, which tells the user that the current
@@ -196,21 +188,13 @@ public:
);
}
- ~FilmChangedDuplicatingDialog ()
- {
- _dialog->Destroy ();
- }
-
- FilmChangedDuplicatingDialog (FilmChangedDuplicatingDialog const&) = delete;
- FilmChangedDuplicatingDialog& operator= (FilmChangedDuplicatingDialog const&) = delete;
-
int run ()
{
return _dialog->ShowModal ();
}
private:
- wxMessageDialog* _dialog;
+ wx_ptr<wxMessageDialog> _dialog;
};
@@ -532,10 +516,7 @@ public:
_film_viewer.set_film(_film);
_film_editor->set_film(_film);
_controls->set_film (_film);
- if (_video_waveform_dialog) {
- _video_waveform_dialog->Destroy ();
- _video_waveform_dialog = nullptr;
- }
+ _video_waveform_dialog.reset();
set_menu_sensitivity ();
if (_film && _film->directory()) {
Config::instance()->add_to_history (_film->directory().get());
@@ -853,12 +834,7 @@ private:
return;
}
- if (_kdm_dialog) {
- _kdm_dialog->Destroy ();
- _kdm_dialog = 0;
- }
-
- _kdm_dialog = new KDMDialog (this, _film);
+ _kdm_dialog.reset(this, _film);
_kdm_dialog->Show ();
}
@@ -868,12 +844,7 @@ private:
return;
}
- if (_dkdm_dialog) {
- _dkdm_dialog->Destroy ();
- _dkdm_dialog = nullptr;
- }
-
- _dkdm_dialog = new DKDMDialog (this, _film);
+ _dkdm_dialog.reset(this, _film);
_dkdm_dialog->Show ();
}
@@ -1074,7 +1045,7 @@ private:
void view_video_waveform ()
{
if (!_video_waveform_dialog) {
- _video_waveform_dialog = new VideoWaveformDialog (this, _film, _film_viewer);
+ _video_waveform_dialog.reset(this, _film, _film_viewer);
}
_video_waveform_dialog->Show ();
@@ -1110,7 +1081,7 @@ private:
void tools_manage_templates ()
{
if (!_templates_dialog) {
- _templates_dialog = new TemplatesDialog (this);
+ _templates_dialog.reset(this);
}
_templates_dialog->Show ();
@@ -1575,14 +1546,14 @@ private:
wxPanel* _right_panel;
FilmViewer _film_viewer;
StandardControls* _controls;
- VideoWaveformDialog* _video_waveform_dialog = nullptr;
+ wx_ptr<VideoWaveformDialog> _video_waveform_dialog;
SystemInformationDialog* _system_information_dialog = nullptr;
HintsDialog* _hints_dialog = nullptr;
ServersListDialog* _servers_list_dialog = nullptr;
wxPreferencesEditor* _config_dialog = nullptr;
- KDMDialog* _kdm_dialog = nullptr;
- DKDMDialog* _dkdm_dialog = nullptr;
- TemplatesDialog* _templates_dialog = nullptr;
+ wx_ptr<KDMDialog> _kdm_dialog;
+ wx_ptr<DKDMDialog> _dkdm_dialog;
+ wx_ptr<TemplatesDialog> _templates_dialog;
wxMenu* _file_menu = nullptr;
shared_ptr<Film> _film;
int _history_items = 0;
diff --git a/src/tools/dcpomatic_disk.cc b/src/tools/dcpomatic_disk.cc
index d3235c1bb..a6ae58c8d 100644
--- a/src/tools/dcpomatic_disk.cc
+++ b/src/tools/dcpomatic_disk.cc
@@ -249,16 +249,14 @@ 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
);
- bool const r = d->ShowModal() == wxID_YES;
- d->Destroy ();
- return r;
+ return d->ShowModal() == wxID_YES;
}
@@ -311,22 +309,20 @@ private:
if (!have_writer) {
#if defined(DCPOMATIC_WINDOWS)
- auto m = new MessageDialog (
+ auto m = make_wx<MessageDialog>(
this,
_("DCP-o-matic Disk Writer"),
_("Do you see a 'User Account Control' dialogue asking about dcpomatic2_disk_writer.exe? If so, click 'Yes', then try again.")
);
m->ShowModal ();
- m->Destroy ();
return;
#elif defined(DCPOMATIC_OSX)
- auto m = new MessageDialog (
+ auto m = make_wx<MessageDialog>(
this,
_("DCP-o-matic Disk Writer"),
_("Did you install the DCP-o-matic Disk Writer.pkg from the .dmg? Please check and try again.")
);
m->ShowModal ();
- m->Destroy ();
return;
#else
LOG_DISK_NC ("Failed to ping writer");
@@ -336,9 +332,8 @@ private:
auto const& drive = _drives[_drive->GetSelection()];
if (drive.mounted()) {
- auto d = new TryUnmountDialog(this, drive.description());
+ auto d = make_wx<TryUnmountDialog>(this, drive.description());
int const r = d->ShowModal ();
- d->Destroy ();
if (r != wxID_OK) {
return;
}
@@ -355,13 +350,12 @@ private:
/* The reply may have to wait for the user to authenticate, so let's wait a while */
auto reply = _nanomsg.receive (30000);
if (!reply || *reply != DISK_WRITER_OK) {
- auto * m = new MessageDialog (
+ auto m = make_wx<MessageDialog>(
this,
_("DCP-o-matic Disk Writer"),
wxString::Format(_("The drive %s could not be unmounted.\nClose any application that is using it, then try again."), std_to_wx(drive.description()))
);
m->ShowModal ();
- m->Destroy ();
return;
}
}
diff --git a/src/tools/dcpomatic_playlist.cc b/src/tools/dcpomatic_playlist.cc
index 2bca4106b..4dc8aef28 100644
--- a/src/tools/dcpomatic_playlist.cc
+++ b/src/tools/dcpomatic_playlist.cc
@@ -551,9 +551,8 @@ private:
void help_about ()
{
- auto d = new AboutDialog (this);
+ auto d = make_wx<AboutDialog>(this);
d->ShowModal ();
- d->Destroy ();
}
void edit_preferences ()