summaryrefslogtreecommitdiff
path: root/src/wx
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/wx
parente8748f158249d7be906f6c6cf2411df45dd07a24 (diff)
Use wx_ptr more.
Diffstat (limited to 'src/wx')
-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
10 files changed, 27 insertions, 84 deletions
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 ();
}