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
);
}
- ~FilmChangedClosingDialog ()
- {
- _dialog->Destroy ();
- }
-
- FilmChangedClosingDialog (FilmChangedClosingDialog const&) = delete;
- FilmChangedClosingDialog& operator= (FilmChangedClosingDialog const&) = delete;
-
int run ()
{
return _dialog->ShowModal ();
}
private:
- wxMessageDialog* _dialog;
+ wx_ptr<wxMessageDialog> _dialog;
};
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
);
}
- ~FilmChangedDuplicatingDialog ()
- {
- _dialog->Destroy ();
- }
-
- FilmChangedDuplicatingDialog (FilmChangedDuplicatingDialog const&) = delete;
- FilmChangedDuplicatingDialog& operator= (FilmChangedDuplicatingDialog const&) = delete;
-
int run ()
{
return _dialog->ShowModal ();
}
private:
- wxMessageDialog* _dialog;
+ wx_ptr<wxMessageDialog> _dialog;
};
_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());
return;
}
- if (_kdm_dialog) {
- _kdm_dialog->Destroy ();
- _kdm_dialog = 0;
- }
-
- _kdm_dialog = new KDMDialog (this, _film);
+ _kdm_dialog.reset(this, _film);
_kdm_dialog->Show ();
}
return;
}
- if (_dkdm_dialog) {
- _dkdm_dialog->Destroy ();
- _dkdm_dialog = nullptr;
- }
-
- _dkdm_dialog = new DKDMDialog (this, _film);
+ _dkdm_dialog.reset(this, _film);
_dkdm_dialog->Show ();
}
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 ();
void tools_manage_templates ()
{
if (!_templates_dialog) {
- _templates_dialog = new TemplatesDialog (this);
+ _templates_dialog.reset(this);
}
_templates_dialog->Show ();
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;
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;
}
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");
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;
}
/* 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;
}
}
void help_about ()
{
- auto d = new AboutDialog (this);
+ auto d = make_wx<AboutDialog>(this);
d->ShowModal ();
- d->Destroy ();
}
void edit_preferences ()
#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"
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
}
-AudioPanel::~AudioPanel ()
-{
- if (_audio_dialog) {
- _audio_dialog->Destroy ();
- _audio_dialog = nullptr;
- }
-}
-
void
AudioPanel::film_changed (Film::Property property)
{
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 ();
}
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();
}
{
public:
explicit AudioPanel (ContentPanel *);
- ~AudioPanel ();
void create () override;
void film_changed (Film::Property) override;
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;
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 ();
}
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;
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();
}
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 ();
}
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;
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();
}
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 ();
}
*/
+#include "wx_ptr.h"
#include "lib/config.h"
#include "lib/film.h"
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;
#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
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 ();
}
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");
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 ();
}