summaryrefslogtreecommitdiff
path: root/src
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
parente8748f158249d7be906f6c6cf2411df45dd07a24 (diff)
Use wx_ptr more.
Diffstat (limited to 'src')
-rw-r--r--src/tools/dcpomatic.cc55
-rw-r--r--src/tools/dcpomatic_disk.cc20
-rw-r--r--src/tools/dcpomatic_playlist.cc3
-rw-r--r--src/wx/audio_mapping_view.cc5
-rw-r--r--src/wx/audio_panel.cc20
-rw-r--r--src/wx/audio_panel.h3
-rw-r--r--src/wx/content_panel.cc7
-rw-r--r--src/wx/content_panel.h2
-rw-r--r--src/wx/dcp_panel.cc53
-rw-r--r--src/wx/dcp_panel.h9
-rw-r--r--src/wx/dir_picker_ctrl.cc4
-rw-r--r--src/wx/kdm_cpl_panel.cc5
-rw-r--r--src/wx/recipient_dialog.cc3
13 files changed, 48 insertions, 141 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 ()
diff --git a/src/wx/audio_mapping_view.cc b/src/wx/audio_mapping_view.cc
index 8818deb63..9c14f61e7 100644
--- a/src/wx/audio_mapping_view.cc
+++ b/src/wx/audio_mapping_view.cc
@@ -26,6 +26,7 @@
#include "audio_gain_dialog.h"
#include "audio_mapping_view.h"
+#include "wx_ptr.h"
#include "wx_util.h"
#include "lib/audio_mapping.h"
#include "lib/maths_util.h"
@@ -550,13 +551,11 @@ AudioMappingView::set_gain_from_menu (double linear)
void
AudioMappingView::edit ()
{
- auto dialog = new AudioGainDialog (this, _menu_input, _menu_output, _map.get(_menu_input, _menu_output));
+ auto dialog = make_wx<AudioGainDialog>(this, _menu_input, _menu_output, _map.get(_menu_input, _menu_output));
if (dialog->ShowModal() == wxID_OK) {
_map.set (_menu_input, _menu_output, dialog->value ());
map_values_changed ();
}
-
- dialog->Destroy ();
}
void
diff --git a/src/wx/audio_panel.cc b/src/wx/audio_panel.cc
index f84c9d67f..81a445efb 100644
--- a/src/wx/audio_panel.cc
+++ b/src/wx/audio_panel.cc
@@ -195,14 +195,6 @@ AudioPanel::add_to_grid ()
}
-AudioPanel::~AudioPanel ()
-{
- if (_audio_dialog) {
- _audio_dialog->Destroy ();
- _audio_dialog = nullptr;
- }
-}
-
void
AudioPanel::film_changed (Film::Property property)
{
@@ -424,17 +416,14 @@ AudioPanel::setup_sensitivity ()
void
AudioPanel::show_clicked ()
{
- if (_audio_dialog) {
- _audio_dialog->Destroy ();
- _audio_dialog = nullptr;
- }
+ _audio_dialog.reset();
auto ac = _parent->selected_audio ();
if (ac.size() != 1) {
return;
}
- _audio_dialog = new AudioDialog (this, _parent->film(), _parent->film_viewer(), ac.front());
+ _audio_dialog.reset(this, _parent->film(), _parent->film_viewer(), ac.front());
_audio_dialog->Show ();
}
@@ -533,10 +522,7 @@ void
AudioPanel::set_film (shared_ptr<Film>)
{
/* We are changing film, so destroy any audio dialog for the old one */
- if (_audio_dialog) {
- _audio_dialog->Destroy ();
- _audio_dialog = nullptr;
- }
+ _audio_dialog.reset();
}
diff --git a/src/wx/audio_panel.h b/src/wx/audio_panel.h
index bd6e0163d..5f03de424 100644
--- a/src/wx/audio_panel.h
+++ b/src/wx/audio_panel.h
@@ -39,7 +39,6 @@ class AudioPanel : public ContentSubPanel
{
public:
explicit AudioPanel (ContentPanel *);
- ~AudioPanel ();
void create () override;
void film_changed (Film::Property) override;
@@ -80,7 +79,7 @@ private:
CheckBox* _use_same_fades_as_video;
AudioMappingView* _mapping;
wxStaticText* _description;
- AudioDialog* _audio_dialog = nullptr;
+ wx_ptr<AudioDialog> _audio_dialog;
boost::signals2::scoped_connection _mapping_connection;
boost::signals2::scoped_connection _active_jobs_connection;
diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc
index 71f32068a..456dbcb56 100644
--- a/src/wx/content_panel.cc
+++ b/src/wx/content_panel.cc
@@ -709,12 +709,7 @@ ContentPanel::timeline_clicked ()
return;
}
- if (_timeline_dialog) {
- _timeline_dialog->Destroy ();
- _timeline_dialog = nullptr;
- }
-
- _timeline_dialog = new TimelineDialog (this, _film, _film_viewer);
+ _timeline_dialog.reset(this, _film, _film_viewer);
_timeline_dialog->set_selection (selected());
_timeline_dialog->Show ();
}
diff --git a/src/wx/content_panel.h b/src/wx/content_panel.h
index 8f25353b3..886860672 100644
--- a/src/wx/content_panel.h
+++ b/src/wx/content_panel.h
@@ -133,7 +133,7 @@ private:
EnumIndexedVector<TextPanel*, TextType> _text_panel;
TimingPanel* _timing_panel;
ContentMenu* _menu;
- TimelineDialog* _timeline_dialog = nullptr;
+ wx_ptr<TimelineDialog> _timeline_dialog;
wxNotebook* _parent;
wxWindow* _last_selected_tab = nullptr;
diff --git a/src/wx/dcp_panel.cc b/src/wx/dcp_panel.cc
index d8aa3ac46..1b97a023d 100644
--- a/src/wx/dcp_panel.cc
+++ b/src/wx/dcp_panel.cc
@@ -327,12 +327,7 @@ DCPPanel::standard_changed ()
void
DCPPanel::markers_clicked ()
{
- if (_markers_dialog) {
- _markers_dialog->Destroy ();
- _markers_dialog = nullptr;
- }
-
- _markers_dialog = new MarkersDialog (_panel, _film, _viewer);
+ _markers_dialog.reset(_panel, _film, _viewer);
_markers_dialog->Show();
}
@@ -341,21 +336,11 @@ void
DCPPanel::metadata_clicked ()
{
if (_film->interop()) {
- if (_interop_metadata_dialog) {
- _interop_metadata_dialog->Destroy ();
- _interop_metadata_dialog = nullptr;
- }
-
- _interop_metadata_dialog = new InteropMetadataDialog (_panel, _film);
+ _interop_metadata_dialog.reset(_panel, _film);
_interop_metadata_dialog->setup ();
_interop_metadata_dialog->Show ();
} else {
- if (_smpte_metadata_dialog) {
- _smpte_metadata_dialog->Destroy ();
- _smpte_metadata_dialog = nullptr;
- }
-
- _smpte_metadata_dialog = new SMPTEMetadataDialog (_panel, _film);
+ _smpte_metadata_dialog.reset(_panel, _film);
_smpte_metadata_dialog->setup ();
_smpte_metadata_dialog->Show ();
}
@@ -586,22 +571,10 @@ void
DCPPanel::set_film (shared_ptr<Film> film)
{
/* We are changing film, so destroy any dialogs for the old one */
- if (_audio_dialog) {
- _audio_dialog->Destroy ();
- _audio_dialog = nullptr;
- }
- if (_markers_dialog) {
- _markers_dialog->Destroy ();
- _markers_dialog = nullptr;
- }
- if (_interop_metadata_dialog) {
- _interop_metadata_dialog->Destroy ();
- _interop_metadata_dialog = nullptr;
- }
- if (_smpte_metadata_dialog) {
- _smpte_metadata_dialog->Destroy ();
- _smpte_metadata_dialog = nullptr;
- }
+ _audio_dialog.reset();
+ _markers_dialog.reset();
+ _interop_metadata_dialog.reset();
+ _smpte_metadata_dialog.reset();
_film = film;
@@ -979,13 +952,8 @@ DCPPanel::show_audio_clicked ()
return;
}
- if (_audio_dialog) {
- _audio_dialog->Destroy ();
- _audio_dialog = nullptr;
- }
-
- auto d = new AudioDialog (_panel, _film, _viewer);
- d->Show ();
+ _audio_dialog.reset(_panel, _film, _viewer);
+ _audio_dialog->Show();
}
@@ -1039,11 +1007,10 @@ void
DCPPanel::edit_audio_language_clicked ()
{
DCPOMATIC_ASSERT (_film->audio_language());
- auto d = new LanguageTagDialog (_panel, *_film->audio_language());
+ auto d = make_wx<LanguageTagDialog>(_panel, *_film->audio_language());
if (d->ShowModal() == wxID_OK) {
_film->set_audio_language(d->get());
}
- d->Destroy ();
}
diff --git a/src/wx/dcp_panel.h b/src/wx/dcp_panel.h
index 7d7f0bd79..cd39f2d1e 100644
--- a/src/wx/dcp_panel.h
+++ b/src/wx/dcp_panel.h
@@ -19,6 +19,7 @@
*/
+#include "wx_ptr.h"
#include "lib/config.h"
#include "lib/film.h"
@@ -159,10 +160,10 @@ private:
wxButton* _metadata;
wxSizer* _audio_panel_sizer;
- AudioDialog* _audio_dialog = nullptr;
- MarkersDialog* _markers_dialog = nullptr;
- InteropMetadataDialog* _interop_metadata_dialog = nullptr;
- SMPTEMetadataDialog* _smpte_metadata_dialog = nullptr;
+ wx_ptr<AudioDialog> _audio_dialog;
+ wx_ptr<MarkersDialog> _markers_dialog;
+ wx_ptr<InteropMetadataDialog> _interop_metadata_dialog;
+ wx_ptr<SMPTEMetadataDialog> _smpte_metadata_dialog;
std::shared_ptr<Film> _film;
FilmViewer& _viewer;
diff --git a/src/wx/dir_picker_ctrl.cc b/src/wx/dir_picker_ctrl.cc
index 6c8fdd1fc..34e54532e 100644
--- a/src/wx/dir_picker_ctrl.cc
+++ b/src/wx/dir_picker_ctrl.cc
@@ -22,6 +22,7 @@
#include "dcpomatic_button.h"
#include "dir_picker_ctrl.h"
#include "static_text.h"
+#include "wx_ptr.h"
#include "wx_util.h"
#include <dcp/warnings.h>
LIBDCP_DISABLE_WARNINGS
@@ -83,9 +84,8 @@ DirPickerCtrl::GetPath () const
void
DirPickerCtrl::browse_clicked ()
{
- wxDirDialog* d = new wxDirDialog (this);
+ auto d = make_wx<wxDirDialog>(this);
if (d->ShowModal () == wxID_OK) {
SetPath (d->GetPath ());
}
- d->Destroy ();
}
diff --git a/src/wx/kdm_cpl_panel.cc b/src/wx/kdm_cpl_panel.cc
index b1bbc1cf0..1ddaa90cf 100644
--- a/src/wx/kdm_cpl_panel.cc
+++ b/src/wx/kdm_cpl_panel.cc
@@ -101,17 +101,14 @@ KDMCPLPanel::update_cpl_summary ()
void
KDMCPLPanel::cpl_browse_clicked ()
{
- wxFileDialog* d = new wxFileDialog (this, _("Select CPL XML file"), wxEmptyString, wxEmptyString, "*.xml");
+ auto d = make_wx<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 dcp_dir = cpl_file.parent_path ();
- d->Destroy ();
-
try {
/* XXX: hack alert */
cxml::Document cpl_document ("CompositionPlaylist");
diff --git a/src/wx/recipient_dialog.cc b/src/wx/recipient_dialog.cc
index 688dcafbd..b685f884a 100644
--- a/src/wx/recipient_dialog.cc
+++ b/src/wx/recipient_dialog.cc
@@ -188,11 +188,10 @@ RecipientDialog::load_recipient (boost::filesystem::path file)
void
RecipientDialog::get_recipient_from_file ()
{
- auto d = new wxFileDialog (this, _("Select Certificate File"));
+ auto d = make_wx<wxFileDialog>(this, _("Select Certificate File"));
if (d->ShowModal () == wxID_OK) {
load_recipient (boost::filesystem::path (wx_to_std (d->GetPath ())));
}
- d->Destroy ();
setup_sensitivity ();
}