diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-02-09 02:06:04 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-02-09 17:29:16 +0100 |
| commit | d0308d53dd9f4d036d8c5fe8023920fcdfd43f39 (patch) | |
| tree | 5b37c1db5dc50e541a542663390061f743fe815a /src/tools | |
| parent | 8d0d9866ae3e0395d899705e27b3806a5de7ef0e (diff) | |
Remove unnecessary wx_ptr
It was only ever used for wxDialog subclasses, which can be
stack-allocated.
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/dcpomatic.cc | 16 | ||||
| -rw-r--r-- | src/tools/dcpomatic_batch.cc | 21 | ||||
| -rw-r--r-- | src/tools/dcpomatic_disk.cc | 26 | ||||
| -rw-r--r-- | src/tools/dcpomatic_player.cc | 39 | ||||
| -rw-r--r-- | src/tools/dcpomatic_playlist.cc | 4 |
5 files changed, 52 insertions, 54 deletions
diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 3d9d571af..7048781e3 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -876,7 +876,7 @@ private: return; } - _kdm_dialog.reset(this, _film); + _kdm_dialog.emplace(this, _film); _kdm_dialog->Show (); } @@ -886,7 +886,7 @@ private: return; } - _dkdm_dialog.reset(this, _film); + _dkdm_dialog.emplace(this, _film); _dkdm_dialog->Show (); } @@ -1083,7 +1083,7 @@ private: void view_video_waveform () { if (!_video_waveform_dialog) { - _video_waveform_dialog.reset(this, _film, _film_viewer); + _video_waveform_dialog.emplace(this, _film, _film_viewer); } _video_waveform_dialog->Show (); @@ -1130,7 +1130,7 @@ private: void tools_manage_templates () { if (!_templates_dialog) { - _templates_dialog.reset(this); + _templates_dialog.emplace(this); } _templates_dialog->Show (); @@ -1578,15 +1578,15 @@ private: wxPanel* _right_panel; FilmViewer _film_viewer; StandardControls* _controls; - wx_ptr<VideoWaveformDialog> _video_waveform_dialog; + boost::optional<VideoWaveformDialog> _video_waveform_dialog; SystemInformationDialog* _system_information_dialog = nullptr; DCPReferencingDialog* _dcp_referencing_dialog = nullptr; HintsDialog* _hints_dialog = nullptr; ServersListDialog* _servers_list_dialog = nullptr; wxPreferencesEditor* _config_dialog = nullptr; - wx_ptr<KDMDialog> _kdm_dialog; - wx_ptr<DKDMDialog> _dkdm_dialog; - wx_ptr<TemplatesDialog> _templates_dialog; + boost::optional<KDMDialog> _kdm_dialog; + boost::optional<DKDMDialog> _dkdm_dialog; + boost::optional<TemplatesDialog> _templates_dialog; wxMenu* _file_menu = nullptr; shared_ptr<Film> _film; int _history_items = 0; diff --git a/src/tools/dcpomatic_batch.cc b/src/tools/dcpomatic_batch.cc index 379a3c074..ed60aae37 100644 --- a/src/tools/dcpomatic_batch.cc +++ b/src/tools/dcpomatic_batch.cc @@ -25,7 +25,6 @@ #include "wx/id.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 "wx/wx_variant.h" @@ -274,14 +273,14 @@ private: return true; } - auto d = make_wx<wxMessageDialog>( + wxMessageDialog dialog( nullptr, _("There are unfinished jobs; are you sure you want to quit?"), _("Unfinished jobs"), wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION ); - return d->ShowModal() == wxID_YES; + return dialog.ShowModal() == wxID_YES; } void close (wxCloseEvent& ev) @@ -326,21 +325,21 @@ private: void help_about () { - auto d = make_wx<AboutDialog>(this); - d->ShowModal (); + AboutDialog dialog(this); + dialog.ShowModal(); } void add_film () { - auto dialog = make_wx<wxDirDialog>(this, _("Select film to open"), wxStandardPaths::Get().GetDocumentsDir(), wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST); + wxDirDialog dialog(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())); + dialog.SetPath(std_to_wx(_last_parent.get().string())); } int r; while (true) { - r = dialog->ShowModal(); - if (r == wxID_OK && dialog->GetPath() == wxStandardPaths::Get().GetDocumentsDir()) { + r = dialog.ShowModal(); + if (r == wxID_OK && dialog.GetPath() == wxStandardPaths::Get().GetDocumentsDir()) { error_dialog (this, _("You did not select a folder. Make sure that you select a folder before clicking Open.")); } else { break; @@ -348,10 +347,10 @@ private: } if (r == wxID_OK) { - start_job(wx_to_std(dialog->GetPath())); + start_job(wx_to_std(dialog.GetPath())); } - _last_parent = boost::filesystem::path(wx_to_std(dialog->GetPath())).parent_path(); + _last_parent = boost::filesystem::path(wx_to_std(dialog.GetPath())).parent_path(); } void config_changed (Config::Property what) diff --git a/src/tools/dcpomatic_disk.cc b/src/tools/dcpomatic_disk.cc index b47addce9..ab603ccad 100644 --- a/src/tools/dcpomatic_disk.cc +++ b/src/tools/dcpomatic_disk.cc @@ -262,14 +262,14 @@ private: return true; } - auto d = make_wx<wxMessageDialog>( + wxMessageDialog dialog( nullptr, _("There are unfinished jobs; are you sure you want to quit?"), _("Unfinished jobs"), wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION ); - return d->ShowModal() == wxID_YES; + return dialog.ShowModal() == wxID_YES; } @@ -323,20 +323,20 @@ private: if (!have_writer) { #if defined(DCPOMATIC_WINDOWS) - auto m = make_wx<MessageDialog>( + MessageDialog dialog( this, variant::wx::dcpomatic_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 (); + dialog.ShowModal(); return; #elif defined(DCPOMATIC_OSX) - auto m = make_wx<MessageDialog>( + MessageDialog dialog( this, variant::wx::dcpomatic_disk_writer(), variant::wx::insert_dcpomatic(_("Did you install the %s Disk Writer.pkg from the .dmg? Please check and try again.")) ); - m->ShowModal (); + dialog.ShowModal(); return; #else LOG_DISK_NC ("Failed to ping writer"); @@ -346,8 +346,8 @@ private: auto const& drive = _drives[_drive->GetSelection()]; if (drive.mounted()) { - auto d = make_wx<TryUnmountDialog>(this, std_to_wx(drive.description())); - int const r = d->ShowModal (); + TryUnmountDialog dialog(this, std_to_wx(drive.description())); + int const r = dialog.ShowModal(); if (r != wxID_OK) { return; } @@ -364,7 +364,7 @@ private: /* The reply may have to wait for the user to authenticate, so let's wait a while */ auto const reply = DiskWriterBackEndResponse::read_from_nanomsg(_nanomsg, 30000); if (!reply || reply->type() != DiskWriterBackEndResponse::Type::OK) { - auto m = make_wx<MessageDialog>( + MessageDialog dialog( this, variant::wx::dcpomatic_disk_writer(), wxString::Format( @@ -373,17 +373,17 @@ private: std_to_wx(reply->error_message()) ) ); - m->ShowModal (); + dialog.ShowModal(); return; } } - auto d = make_wx<DriveWipeWarningDialog>(this, _drive->GetString(_drive->GetSelection())); - if (d->ShowModal() != wxID_OK) { + DriveWipeWarningDialog dialog(this, _drive->GetString(_drive->GetSelection())); + if (dialog.ShowModal() != wxID_OK) { return; } - if (!d->confirmed()) { + if (!dialog.confirmed()) { message_dialog(this, _("You did not correctly confirm that you read the warning that was just shown. Please try again.")); return; } diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc index 0a45988a7..043e5f48b 100644 --- a/src/tools/dcpomatic_player.cc +++ b/src/tools/dcpomatic_player.cc @@ -34,7 +34,6 @@ #include "wx/update_dialog.h" #include "wx/verify_dcp_progress_dialog.h" #include "wx/verify_dcp_result_dialog.h" -#include "wx/wx_ptr.h" #include "wx/wx_signal_manager.h" #include "wx/wx_util.h" #include "wx/wx_variant.h" @@ -680,12 +679,12 @@ private: d = std_to_wx (Config::instance()->last_player_load_directory()->string()); } - auto c = make_wx<wxDirDialog>(this, _("Select DCP to open"), d, wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST); + wxDirDialog dialog(this, _("Select DCP to open"), d, wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST); int r; while (true) { - r = c->ShowModal (); - if (r == wxID_OK && c->GetPath() == wxStandardPaths::Get().GetDocumentsDir()) { + r = dialog.ShowModal(); + if (r == wxID_OK && dialog.GetPath() == wxStandardPaths::Get().GetDocumentsDir()) { error_dialog (this, _("You did not select a folder. Make sure that you select a folder before clicking Open.")); } else { break; @@ -693,7 +692,7 @@ private: } if (r == wxID_OK) { - boost::filesystem::path const dcp (wx_to_std (c->GetPath ())); + boost::filesystem::path const dcp(wx_to_std(dialog.GetPath ())); load_dcp (dcp); Config::instance()->set_last_player_load_directory (dcp.parent_path()); } @@ -706,7 +705,7 @@ private: initial_dir = std_to_wx(Config::instance()->last_player_load_directory()->string()); } - auto c = make_wx<wxDirDialog>( + wxDirDialog dialog( this, _("Select DCP to open as OV"), initial_dir, @@ -715,8 +714,8 @@ private: int r; while (true) { - r = c->ShowModal (); - if (r == wxID_OK && c->GetPath() == wxStandardPaths::Get().GetDocumentsDir()) { + r = dialog.ShowModal(); + if (r == wxID_OK && dialog.GetPath() == wxStandardPaths::Get().GetDocumentsDir()) { error_dialog (this, _("You did not select a folder. Make sure that you select a folder before clicking Open.")); } else { break; @@ -730,7 +729,7 @@ private: DCPOMATIC_ASSERT(dcp); try { - dcp->add_ov(wx_to_std(c->GetPath())); + dcp->add_ov(wx_to_std(dialog.GetPath())); } catch (DCPError& e) { error_dialog(this, char_to_wx(e.what())); return; @@ -1000,14 +999,14 @@ private: void tools_timing () { - auto d = make_wx<TimerDisplay>(this, _viewer.state_timer(), _viewer.gets()); - d->ShowModal (); + TimerDisplay dialog(this, _viewer.state_timer(), _viewer.gets()); + dialog.ShowModal(); } void tools_system_information () { if (!_system_information_dialog) { - _system_information_dialog = new SystemInformationDialog (this, _viewer); + _system_information_dialog.emplace(this, _viewer); } _system_information_dialog->Show (); @@ -1015,15 +1014,15 @@ private: void help_about () { - auto d = make_wx<AboutDialog>(this); - d->ShowModal (); + AboutDialog dialog(this); + dialog.ShowModal(); } void help_report_a_problem () { - auto d = make_wx<ReportProblemDialog>(this); - if (d->ShowModal () == wxID_OK) { - d->report (); + ReportProblemDialog dialog(this); + if (dialog.ShowModal() == wxID_OK) { + dialog.report(); } } @@ -1043,8 +1042,8 @@ private: } if (uc->state() == UpdateChecker::State::YES) { - auto dialog = make_wx<UpdateDialog>(this, uc->stable (), uc->test ()); - dialog->ShowModal (); + UpdateDialog dialog(this, uc->stable (), uc->test ()); + dialog.ShowModal(); } else if (uc->state() == UpdateChecker::State::FAILED) { error_dialog(this, variant::wx::insert_dcpomatic(_("The %s download server could not be contacted."))); } else { @@ -1223,7 +1222,7 @@ private: wxMenuItem* _history_separator = nullptr; FilmViewer _viewer; Controls* _controls; - SystemInformationDialog* _system_information_dialog = nullptr; + boost::optional<SystemInformationDialog> _system_information_dialog; std::shared_ptr<Film> _film; boost::signals2::scoped_connection _config_changed_connection; boost::signals2::scoped_connection _examine_job_connection; diff --git a/src/tools/dcpomatic_playlist.cc b/src/tools/dcpomatic_playlist.cc index 7798c3278..dfe578194 100644 --- a/src/tools/dcpomatic_playlist.cc +++ b/src/tools/dcpomatic_playlist.cc @@ -545,8 +545,8 @@ private: void help_about () { - auto d = make_wx<AboutDialog>(this); - d->ShowModal (); + AboutDialog dialog(this); + dialog.ShowModal(); } void edit_preferences () |
