More c++ tidying.
authorCarl Hetherington <cth@carlh.net>
Sat, 9 Jan 2021 00:29:24 +0000 (01:29 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 9 Jan 2021 00:29:24 +0000 (01:29 +0100)
src/tools/dcpomatic.cc
src/wx/about_dialog.cc
src/wx/content_panel.cc
src/wx/dcp_panel.cc
src/wx/wx_util.cc

index bcef19f59bf608f8442242694d7b09802c543d7e..0db26566aec8f1f5147f80ce0c748f0961f265b4 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -123,6 +123,7 @@ using std::map;
 using std::make_pair;
 using std::list;
 using std::exception;
+using std::make_shared;
 using std::shared_ptr;
 using std::dynamic_pointer_cast;
 using boost::optional;
@@ -293,7 +294,7 @@ public:
                }
 #endif
 
-               wxMenuBar* bar = new wxMenuBar;
+               auto bar = new wxMenuBar;
                setup_menu (bar);
                SetMenuBar (bar);
 
@@ -351,9 +352,9 @@ public:
                _film_viewer.reset (new FilmViewer (overall_panel));
                _controls = new StandardControls (overall_panel, _film_viewer, true);
                _film_editor = new FilmEditor (overall_panel, _film_viewer);
-               JobManagerView* job_manager_view = new JobManagerView (overall_panel, false);
+               auto job_manager_view = new JobManagerView (overall_panel, false);
 
-               wxBoxSizer* right_sizer = new wxBoxSizer (wxVERTICAL);
+               auto right_sizer = new wxBoxSizer (wxVERTICAL);
                right_sizer->Add (_film_viewer->panel(), 2, wxEXPAND | wxALL, 6);
                right_sizer->Add (_controls, 0, wxEXPAND | wxALL, 6);
                right_sizer->Add (job_manager_view, 1, wxEXPAND | wxALL, 6);
@@ -421,7 +422,7 @@ public:
 
        void new_film (boost::filesystem::path path, optional<string> template_name)
        {
-               shared_ptr<Film> film (new Film (path));
+               auto film = make_shared<Film>(path);
                if (template_name) {
                        film->use_template (template_name.get());
                }
@@ -433,8 +434,8 @@ public:
        void load_film (boost::filesystem::path file)
        try
        {
-               shared_ptr<Film> film (new Film (file));
-               list<string> const notes = film->read_metadata ();
+               auto film = make_shared<Film>(file);
+               auto const notes = film->read_metadata ();
 
                if (film->state_version() == 4) {
                        error_dialog (
@@ -453,19 +454,19 @@ public:
                JobManager::instance()->add(shared_ptr<Job>(new CheckContentChangeJob(film)));
        }
        catch (FileNotFoundError& e) {
-               boost::filesystem::path const dir = e.file().parent_path();
+               auto const dir = e.file().parent_path();
                if (boost::filesystem::exists(dir / "ASSETMAP") || boost::filesystem::exists(dir / "ASSETMAP.xml")) {
                        error_dialog (
                                this, _("Could not open this folder as a DCP-o-matic project."),
                                _("It looks like you are trying to open a DCP.  File -> Open is for loading DCP-o-matic projects, not DCPs.  To import a DCP, create a new project with File -> New and then click the \"Add DCP...\" button.")
                                );
                } else {
-                       wxString const p = std_to_wx(file.string ());
+                       auto const p = std_to_wx(file.string ());
                        error_dialog (this, wxString::Format(_("Could not open film at %s"), p.data()), std_to_wx(e.what()));
                }
 
        } catch (std::exception& e) {
-               wxString const p = std_to_wx (file.string());
+               auto const p = std_to_wx (file.string());
                error_dialog (this, wxString::Format(_("Could not open film at %s"), p.data()), std_to_wx(e.what()));
        }
 
@@ -518,7 +519,7 @@ private:
 
        void file_changed (boost::filesystem::path f)
        {
-               string s = wx_to_std (_("DCP-o-matic"));
+               auto s = wx_to_std(_("DCP-o-matic"));
                if (!f.empty ()) {
                        s += " - " + f.string ();
                }
@@ -528,7 +529,7 @@ private:
 
        void file_new ()
        {
-               FilmNameLocationDialog* d = new FilmNameLocationDialog (this, _("New Film"), true);
+               auto d = new FilmNameLocationDialog (this, _("New Film"), true);
                int const r = d->ShowModal ();
 
                if (r == wxID_OK && d->check_path() && maybe_save_then_delete_film<FilmChangedClosingDialog>()) {
@@ -563,7 +564,7 @@ private:
 
        void file_open ()
        {
-               wxDirDialog* c = new wxDirDialog (
+               auto c = new wxDirDialog (
                        this,
                        _("Select film to open"),
                        std_to_wx (Config::instance()->default_directory_or (wx_to_std (wxStandardPaths::Get().GetDocumentsDir())).string ()),
@@ -594,7 +595,7 @@ private:
 
        void file_save_as_template ()
        {
-               SaveTemplateDialog* d = new SaveTemplateDialog (this);
+               auto d = new SaveTemplateDialog (this);
                int const r = d->ShowModal ();
                if (r == wxID_OK) {
                        Config::instance()->save_template (_film, d->name ());
@@ -604,7 +605,7 @@ private:
 
        void file_duplicate ()
        {
-               FilmNameLocationDialog* d = new FilmNameLocationDialog (this, _("Duplicate Film"), false);
+               auto d = new FilmNameLocationDialog (this, _("Duplicate Film"), false);
                int const r = d->ShowModal ();
 
                if (r == wxID_OK && d->check_path() && maybe_save_film<FilmChangedDuplicatingDialog>()) {
@@ -619,7 +620,7 @@ private:
 
        void file_duplicate_and_open ()
        {
-               FilmNameLocationDialog* d = new FilmNameLocationDialog (this, _("Duplicate Film"), false);
+               auto d = new FilmNameLocationDialog (this, _("Duplicate Film"), false);
                int const r = d->ShowModal ();
 
                if (r == wxID_OK && d->check_path() && maybe_save_film<FilmChangedDuplicatingDialog>()) {
@@ -637,7 +638,7 @@ private:
        {
                if (_film && _film->dirty ()) {
 
-                       FilmChangedClosingDialog* dialog = new FilmChangedClosingDialog (_film->name ());
+                       auto dialog = new FilmChangedClosingDialog (_film->name ());
                        int const r = dialog->run ();
                        delete dialog;
 
@@ -660,7 +661,7 @@ private:
 
        void file_history (wxCommandEvent& event)
        {
-               vector<boost::filesystem::path> history = Config::instance()->history ();
+               auto history = Config::instance()->history ();
                int n = event.GetId() - ID_file_history;
                if (n >= 0 && n < static_cast<int> (history.size ()) && maybe_save_then_delete_film<FilmChangedClosingDialog>()) {
                        load_film (history[n]);
@@ -675,7 +676,7 @@ private:
 
        void edit_copy ()
        {
-               ContentList const sel = _film_editor->content_panel()->selected();
+               auto const sel = _film_editor->content_panel()->selected();
                DCPOMATIC_ASSERT (sel.size() == 1);
                _clipboard = sel.front()->clone();
        }
@@ -684,7 +685,7 @@ private:
        {
                DCPOMATIC_ASSERT (_clipboard);
 
-               PasteDialog* d = new PasteDialog (this, static_cast<bool>(_clipboard->video), static_cast<bool>(_clipboard->audio), !_clipboard->text.empty());
+               auto d = new PasteDialog (this, static_cast<bool>(_clipboard->video), static_cast<bool>(_clipboard->audio), !_clipboard->text.empty());
                if (d->ShowModal() == wxID_OK) {
                        for (auto i: _film_editor->content_panel()->selected()) {
                                if (d->video() && i->video) {
@@ -697,8 +698,8 @@ private:
                                }
 
                                if (d->text()) {
-                                       list<shared_ptr<TextContent> >::iterator j = i->text.begin ();
-                                       list<shared_ptr<TextContent> >::const_iterator k = _clipboard->text.begin ();
+                                       auto j = i->text.begin ();
+                                       auto k = _clipboard->text.begin ();
                                        while (j != i->text.end() && k != _clipboard->text.end()) {
                                                (*j)->take_settings_from (*k);
                                                ++j;
@@ -720,7 +721,7 @@ private:
 
        void tools_restore_default_preferences ()
        {
-               wxMessageDialog* d = new wxMessageDialog (
+               auto d = new wxMessageDialog (
                        0,
                        _("Are you sure you want to restore preferences to their defaults?  This cannot be undone."),
                        _("Restore default preferences"),
@@ -754,7 +755,7 @@ private:
                }
 
                if (Config::instance()->show_hints_before_make_dcp()) {
-                       HintsDialog* hints = new HintsDialog (this, _film, false);
+                       auto hints = new HintsDialog (this, _film, false);
                        int const r = hints->ShowModal();
                        hints->Destroy ();
                        if (r == wxID_CANCEL) {
@@ -868,7 +869,7 @@ private:
                }
 
                if (Config::instance()->show_hints_before_make_dcp()) {
-                       HintsDialog* hints = new HintsDialog (this, _film, false);
+                       auto hints = new HintsDialog (this, _film, false);
                        int const r = hints->ShowModal();
                        hints->Destroy ();
                        if (r == wxID_CANCEL) {
@@ -908,7 +909,7 @@ private:
                        return;
                }
 
-               SelfDKDMDialog* d = new SelfDKDMDialog (this, _film);
+               auto d = new SelfDKDMDialog (this, _film);
                if (d->ShowModal () != wxID_OK) {
                        d->Destroy ();
                        return;
@@ -952,11 +953,11 @@ private:
 
                if (kdm) {
                        if (d->internal ()) {
-                               shared_ptr<DKDMGroup> dkdms = Config::instance()->dkdms ();
+                               auto dkdms = Config::instance()->dkdms();
                                dkdms->add (shared_ptr<DKDM> (new DKDM (kdm.get())));
                                Config::instance()->changed ();
                        } else {
-                               boost::filesystem::path path = d->directory() / (_film->dcp_name(false) + "_DKDM.xml");
+                               auto path = d->directory() / (_film->dcp_name(false) + "_DKDM.xml");
                                kdm->as_xml (path);
                        }
                }
@@ -967,7 +968,7 @@ private:
 
        void jobs_export_video_file ()
        {
-               ExportVideoFileDialog* d = new ExportVideoFileDialog (this, _film->isdcf_name(true));
+               auto d = new ExportVideoFileDialog (this, _film->isdcf_name(true));
                if (d->ShowModal() == wxID_OK) {
                        if (boost::filesystem::exists(d->path())) {
                                bool ok = confirm_dialog(
@@ -981,11 +982,10 @@ private:
                                }
                        }
 
-                       shared_ptr<TranscodeJob> job (new TranscodeJob (_film));
+                       auto job = make_shared<TranscodeJob>(_film);
                        job->set_encoder (
-                               shared_ptr<FFmpegEncoder> (
-                                       new FFmpegEncoder (_film, job, d->path(), d->format(), d->mixdown_to_stereo(), d->split_reels(), d->split_streams(), d->x264_crf())
-                                       )
+                               make_shared<FFmpegEncoder> (
+                                       _film, job, d->path(), d->format(), d->mixdown_to_stereo(), d->split_reels(), d->split_streams(), d->x264_crf())
                                );
                        JobManager::instance()->add (job);
                }
@@ -995,11 +995,11 @@ private:
 
        void jobs_export_subtitles ()
        {
-               ExportSubtitlesDialog* d = new ExportSubtitlesDialog (this, _film->reels().size(), _film->interop());
+               auto d = new ExportSubtitlesDialog (this, _film->reels().size(), _film->interop());
                if (d->ShowModal() == wxID_OK) {
-                       shared_ptr<TranscodeJob> job (new TranscodeJob (_film));
+                       auto job = make_shared<TranscodeJob>(_film);
                        job->set_encoder (
-                               shared_ptr<SubtitleEncoder>(new SubtitleEncoder(_film, job, d->path(), _film->isdcf_name(true), d->split_reels(), d->include_font()))
+                               make_shared<SubtitleEncoder>(_film, job, d->path(), _film->isdcf_name(true), d->split_reels(), d->include_font())
                                );
                        JobManager::instance()->add (job);
                }
@@ -1105,19 +1105,18 @@ private:
 
        void tools_send_translations ()
        {
-               SendI18NDialog* d = new SendI18NDialog (this);
+               auto d = new SendI18NDialog (this);
                if (d->ShowModal() == wxID_OK) {
                        string body;
                        body += d->name() + "\n";
                        body += d->language() + "\n";
                        body += string(dcpomatic_version) + " " + string(dcpomatic_git_commit) + "\n";
                        body += "--\n";
-                       map<string, string> translations = I18NHook::translations ();
-                       for (map<string, string>::const_iterator i = translations.begin(); i != translations.end(); ++i) {
-                               body += i->first + "\n" + i->second + "\n\n";
+                       auto translations = I18NHook::translations ();
+                       for (auto i: translations) {
+                               body += i.first + "\n" + i.second + "\n\n";
                        }
-                       list<string> to;
-                       to.push_back ("carl@dcpomatic.com");
+                       list<string> to = { "carl@dcpomatic.com" };
                        Emailer emailer (d->email(), to, "DCP-o-matic translations", body);
                        emailer.send ("main.carlh.net", 2525, EMAIL_PROTOCOL_STARTTLS);
                }
@@ -1127,14 +1126,14 @@ private:
 
        void help_about ()
        {
-               AboutDialog* d = new AboutDialog (this);
+               auto d = new AboutDialog (this);
                d->ShowModal ();
                d->Destroy ();
        }
 
        void help_report_a_problem ()
        {
-               ReportProblemDialog* d = new ReportProblemDialog (this, _film);
+               auto d = new ReportProblemDialog (this, _film);
                if (d->ShowModal () == wxID_OK) {
                        d->report ();
                }
@@ -1147,7 +1146,7 @@ private:
                        return true;
                }
 
-               wxMessageDialog* d = new wxMessageDialog (
+               auto d = new wxMessageDialog (
                        0,
                        _("There are unfinished jobs; are you sure you want to quit?"),
                        _("Unfinished jobs"),
@@ -1168,7 +1167,7 @@ private:
 
                if (_film && _film->dirty ()) {
 
-                       FilmChangedClosingDialog* dialog = new FilmChangedClosingDialog (_film->name ());
+                       auto dialog = new FilmChangedClosingDialog (_film->name ());
                        int const r = dialog->run ();
                        delete dialog;
 
@@ -1201,8 +1200,8 @@ private:
 
        void set_menu_sensitivity ()
        {
-               list<shared_ptr<Job> > jobs = JobManager::instance()->get ();
-               list<shared_ptr<Job> >::iterator i = jobs.begin();
+               auto jobs = JobManager::instance()->get ();
+               auto i = jobs.begin();
                while (i != jobs.end() && (*i)->json_name() != "transcode") {
                        ++i;
                }
@@ -1212,43 +1211,43 @@ private:
                bool const have_selected_content = !_film_editor->content_panel()->selected().empty();
                bool const have_selected_video_content = !_film_editor->content_panel()->selected_video().empty();
 
-               for (map<wxMenuItem*, int>::iterator j = menu_items.begin(); j != menu_items.end(); ++j) {
+               for (auto j: menu_items) {
 
                        bool enabled = true;
 
-                       if ((j->second & NEEDS_FILM) && !_film) {
+                       if ((j.second & NEEDS_FILM) && !_film) {
                                enabled = false;
                        }
 
-                       if ((j->second & NOT_DURING_DCP_CREATION) && dcp_creation) {
+                       if ((j.second & NOT_DURING_DCP_CREATION) && dcp_creation) {
                                enabled = false;
                        }
 
-                       if ((j->second & NEEDS_CPL) && !have_cpl) {
+                       if ((j.second & NEEDS_CPL) && !have_cpl) {
                                enabled = false;
                        }
 
-                       if ((j->second & NEEDS_SELECTED_CONTENT) && !have_selected_content) {
+                       if ((j.second & NEEDS_SELECTED_CONTENT) && !have_selected_content) {
                                enabled = false;
                        }
 
-                       if ((j->second & NEEDS_SINGLE_SELECTED_CONTENT) && !have_single_selected_content) {
+                       if ((j.second & NEEDS_SINGLE_SELECTED_CONTENT) && !have_single_selected_content) {
                                enabled = false;
                        }
 
-                       if ((j->second & NEEDS_SELECTED_VIDEO_CONTENT) && !have_selected_video_content) {
+                       if ((j.second & NEEDS_SELECTED_VIDEO_CONTENT) && !have_selected_video_content) {
                                enabled = false;
                        }
 
-                       if ((j->second & NEEDS_CLIPBOARD) && !_clipboard) {
+                       if ((j.second & NEEDS_CLIPBOARD) && !_clipboard) {
                                enabled = false;
                        }
 
-                       if ((j->second & NEEDS_ENCRYPTION) && (!_film || !_film->encrypted())) {
+                       if ((j.second & NEEDS_ENCRYPTION) && (!_film || !_film->encrypted())) {
                                enabled = false;
                        }
 
-                       j->first->Enable (enabled);
+                       j.first->Enable (enabled);
                }
        }
 
@@ -1290,7 +1289,7 @@ private:
 
        void add_item (wxMenu* menu, wxString text, int id, int sens)
        {
-               wxMenuItem* item = menu->Append (id, text);
+               auto item = menu->Append (id, text);
                menu_items.insert (make_pair (item, sens));
        }
 
@@ -1427,7 +1426,7 @@ private:
 
                /* Clear out non-existant history items before we re-build the menu */
                Config::instance()->clean_history ();
-               vector<boost::filesystem::path> history = Config::instance()->history ();
+               auto history = Config::instance()->history();
 
                if (!history.empty ()) {
                        _history_separator = _file_menu->InsertSeparator (pos++);
@@ -1450,7 +1449,7 @@ private:
 
        void update_checker_state_changed ()
        {
-               UpdateChecker* uc = UpdateChecker::instance ();
+               auto uc = UpdateChecker::instance ();
 
                bool const announce =
                        _update_news_requested ||
@@ -1464,7 +1463,7 @@ private:
                }
 
                if (uc->state() == UpdateChecker::YES) {
-                       UpdateDialog* dialog = new UpdateDialog (this, uc->stable (), uc->test ());
+                       auto dialog = new UpdateDialog (this, uc->stable(), uc->test());
                        dialog->ShowModal ();
                        dialog->Destroy ();
                } else if (uc->state() == UpdateChecker::FAILED) {
@@ -1502,7 +1501,7 @@ private:
 
        void analytics_message (string title, string html)
        {
-               HTMLDialog* d = new HTMLDialog(this, std_to_wx(title), std_to_wx(html));
+               auto d = new HTMLDialog(this, std_to_wx(title), std_to_wx(html));
                d->ShowModal();
                d->Destroy();
        }
@@ -1658,9 +1657,9 @@ private:
                {
                        if (_splash) {
                                _splash->Destroy ();
-                               _splash = 0;
+                               _splash = nullptr;
                        }
-                       error_dialog (0, wxString::Format ("DCP-o-matic could not start."), std_to_wx(e.what()));
+                       error_dialog (nullptr, wxString::Format ("DCP-o-matic could not start."), std_to_wx(e.what()));
                }
 
                return true;
@@ -1720,7 +1719,7 @@ private:
                                );
                } catch (exception& e) {
                        error_dialog (
-                               0,
+                               nullptr,
                                wxString::Format (
                                        _("An exception occurred: %s.\n\n") + REPORT_PROBLEM,
                                        std_to_wx (e.what ())
@@ -1785,16 +1784,16 @@ private:
                   when we open our recreate dialog, close it, *then* try to Destroy the splash (the Destroy fails).
                */
                _splash->Destroy ();
-               _splash = 0;
+               _splash = nullptr;
 
-               Config* config = Config::instance();
+               auto config = Config::instance();
                switch (reason) {
                case Config::BAD_SIGNER_UTF8_STRINGS:
                {
                        if (config->nagged(Config::NAG_BAD_SIGNER_CHAIN)) {
                                return false;
                        }
-                       RecreateChainDialog* d = new RecreateChainDialog (
+                       auto d = new RecreateChainDialog (
                                _frame, _("Recreate signing certificates"),
                                _("The certificate chain that DCP-o-matic uses for signing DCPs and KDMs contains a small error\n"
                                  "which will prevent DCPs from being validated correctly on some systems.  Do you want to re-create\n"
@@ -1808,7 +1807,7 @@ private:
                }
                case Config::BAD_SIGNER_INCONSISTENT:
                {
-                       RecreateChainDialog* d = new RecreateChainDialog (
+                       auto d = new RecreateChainDialog (
                                _frame, _("Recreate signing certificates"),
                                _("The certificate chain that DCP-o-matic uses for signing DCPs and KDMs is inconsistent and\n"
                                  "cannot be used.  DCP-o-matic cannot start unless you re-create it.  Do you want to re-create\n"
@@ -1824,7 +1823,7 @@ private:
                }
                case Config::BAD_DECRYPTION_INCONSISTENT:
                {
-                       RecreateChainDialog* d = new RecreateChainDialog (
+                       auto d = new RecreateChainDialog (
                                _frame, _("Recreate KDM decryption chain"),
                                _("The certificate chain that DCP-o-matic uses for decrypting KDMs is inconsistent and\n"
                                  "cannot be used.  DCP-o-matic cannot start unless you re-create it.  Do you want to re-create\n"
index ae2bf0d0aae781f794de1033d804d1789da2b32a..5c13be5514aefc8014336109c9ff341fbc45a109 100644 (file)
@@ -38,8 +38,8 @@ using std::vector;
 AboutDialog::AboutDialog (wxWindow* parent)
        : wxDialog (parent, wxID_ANY, _("About DCP-o-matic"))
 {
-       wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
-       wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
+       auto overall_sizer = new wxBoxSizer (wxVERTICAL);
+       auto sizer = new wxBoxSizer (wxVERTICAL);
 
        wxFont title_font (*wxNORMAL_FONT);
        title_font.SetPointSize (title_font.GetPointSize() + 12);
@@ -51,7 +51,7 @@ AboutDialog::AboutDialog (wxWindow* parent)
        wxFont version_font (*wxNORMAL_FONT);
        version_font.SetWeight (wxFONTWEIGHT_BOLD);
 
-       wxStaticText* t = new StaticText (this, _("DCP-o-matic"));
+       auto t = new StaticText (this, _("DCP-o-matic"));
        t->SetFont (title_font);
        sizer->Add (t, wxSizerFlags().Centre().Border(wxALL, 16));
 
@@ -74,7 +74,7 @@ AboutDialog::AboutDialog (wxWindow* parent)
 
        sizer->Add (t, wxSizerFlags().Centre().Border(wxALL, 8));
 
-       wxHyperlinkCtrl* h = new wxHyperlinkCtrl (
+       auto h = new wxHyperlinkCtrl (
                this, wxID_ANY,
                wxT ("dcpomatic.com"),
                wxT ("https://dcpomatic.com")
@@ -238,14 +238,14 @@ AboutDialog::AboutDialog (wxWindow* parent)
 void
 AboutDialog::add_section (wxString name, wxArrayString credits)
 {
-       static bool first = true;
+       static auto first = true;
        int const N = 4;
 
-       wxScrolledWindow* panel = new wxScrolledWindow (_notebook);
+       auto panel = new wxScrolledWindow (_notebook);
        panel->SetMaxSize (wxSize (-1, 380));
        panel->EnableScrolling (false, true);
        panel->SetScrollRate (0, 32);
-       wxSizer* overall_sizer = new wxBoxSizer (wxHORIZONTAL);
+       auto overall_sizer = new wxBoxSizer (wxHORIZONTAL);
 
        vector<wxSizer*> sizers;
 
index 83539403d7ed704b5f63403664ecfef4c3cd8da2..0530c9128453f85606d4032d73e8fa7b5bb6d73b 100644 (file)
@@ -88,7 +88,7 @@ ContentPanel::ContentPanel (wxNotebook* n, shared_ptr<Film> film, weak_ptr<FilmV
        _menu = new ContentMenu (_splitter);
 
        {
-               wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
+               auto s = new wxBoxSizer (wxHORIZONTAL);
 
                _content = new wxListCtrl (_top_panel, wxID_ANY, wxDefaultPosition, wxSize (320, 160), wxLC_REPORT | wxLC_NO_HEADER);
                _content->DragAcceptFiles (true);
@@ -97,7 +97,7 @@ ContentPanel::ContentPanel (wxNotebook* n, shared_ptr<Film> film, weak_ptr<FilmV
                _content->InsertColumn (0, wxT(""));
                _content->SetColumnWidth (0, 512);
 
-               wxBoxSizer* b = new wxBoxSizer (wxVERTICAL);
+               auto b = new wxBoxSizer (wxVERTICAL);
 
                _add_file = new Button (_top_panel, _("Add file(s)..."));
                _add_file->SetToolTip (_("Add video, image, sound or subtitle files to the film."));
@@ -168,7 +168,7 @@ ContentPanel::selected ()
                        break;
                }
 
-               ContentList cl = _film->content();
+               auto cl = _film->content();
                if (s < int (cl.size())) {
                        sel.push_back (cl[s]);
                }
@@ -225,7 +225,7 @@ ContentPanel::selected_ffmpeg ()
        FFmpegContentList sc;
 
        for (auto i: selected()) {
-               shared_ptr<FFmpegContent> t = dynamic_pointer_cast<FFmpegContent> (i);
+               auto t = dynamic_pointer_cast<FFmpegContent> (i);
                if (t) {
                        sc.push_back (t);
                }
@@ -308,7 +308,7 @@ ContentPanel::check_selection ()
        }
 
        if (go_to && Config::instance()->jump_to_selected() && signal_manager) {
-               shared_ptr<FilmViewer> fv = _film_viewer.lock ();
+               auto fv = _film_viewer.lock ();
                DCPOMATIC_ASSERT (fv);
                signal_manager->when_idle(boost::bind(&FilmViewer::seek, fv.get(), go_to.get().ceil(_film->video_frame_rate()), true));
        }
@@ -385,7 +385,7 @@ ContentPanel::check_selection ()
 
        /* Set up the tab selection */
 
-       bool done = false;
+       auto done = false;
        for (size_t i = 0; i < _notebook->GetPageCount(); ++i) {
                if (_notebook->GetPage(i) == _last_selected_tab) {
                        _notebook->SetSelection (i);
@@ -414,7 +414,7 @@ ContentPanel::add_file_clicked ()
        /* The wxFD_CHANGE_DIR here prevents a `could not set working directory' error 123 on Windows when using
           non-Latin filenames or paths.
        */
-       wxFileDialog* d = new wxFileDialog (
+       auto d = new wxFileDialog (
                _splitter,
                _("Choose a file or files"),
                wxT (""),
@@ -444,7 +444,7 @@ ContentPanel::add_file_clicked ()
 void
 ContentPanel::add_folder_clicked ()
 {
-       wxDirDialog* d = new wxDirDialog (_splitter, _("Choose a folder"), wxT(""), wxDD_DIR_MUST_EXIST);
+       auto d = new wxDirDialog (_splitter, _("Choose a folder"), wxT(""), wxDD_DIR_MUST_EXIST);
        int r = d->ShowModal ();
        boost::filesystem::path const path (wx_to_std (d->GetPath ()));
        d->Destroy ();
@@ -468,11 +468,11 @@ ContentPanel::add_folder_clicked ()
        }
 
        for (auto i: content) {
-               shared_ptr<ImageContent> ic = dynamic_pointer_cast<ImageContent> (i);
+               auto ic = dynamic_pointer_cast<ImageContent> (i);
                if (ic) {
-                       ImageSequenceDialog* e = new ImageSequenceDialog (_splitter);
+                       auto e = new ImageSequenceDialog (_splitter);
                        r = e->ShowModal ();
-                       float const frame_rate = e->frame_rate ();
+                       auto const frame_rate = e->frame_rate ();
                        e->Destroy ();
 
                        if (r != wxID_OK) {
@@ -489,7 +489,7 @@ ContentPanel::add_folder_clicked ()
 void
 ContentPanel::add_dcp_clicked ()
 {
-       wxDirDialog* d = new wxDirDialog (_splitter, _("Choose a DCP folder"), wxT(""), wxDD_DIR_MUST_EXIST);
+       auto d = new wxDirDialog (_splitter, _("Choose a DCP folder"), wxT(""), wxDD_DIR_MUST_EXIST);
        int r = d->ShowModal ();
        boost::filesystem::path const path (wx_to_std (d->GetPath ()));
        d->Destroy ();
@@ -533,7 +533,7 @@ ContentPanel::timeline_clicked ()
 
        if (_timeline_dialog) {
                _timeline_dialog->Destroy ();
-               _timeline_dialog = 0;
+               _timeline_dialog = nullptr;
        }
 
        _timeline_dialog = new TimelineDialog (this, _film, _film_viewer);
@@ -555,9 +555,9 @@ ContentPanel::setup_sensitivity ()
        _add_folder->Enable (_generally_sensitive);
        _add_dcp->Enable (_generally_sensitive);
 
-       ContentList selection = selected ();
-       ContentList video_selection = selected_video ();
-       ContentList audio_selection = selected_audio ();
+       auto selection = selected ();
+       auto video_selection = selected_video ();
+       auto audio_selection = selected_audio ();
 
        _remove->Enable   (_generally_sensitive && !selection.empty());
        _earlier->Enable  (_generally_sensitive && selection.size() == 1);
@@ -607,7 +607,7 @@ ContentPanel::set_general_sensitivity (bool s)
 void
 ContentPanel::earlier_clicked ()
 {
-       ContentList sel = selected ();
+       auto sel = selected ();
        if (sel.size() == 1) {
                _film->move_content_earlier (sel.front ());
                check_selection ();
@@ -617,7 +617,7 @@ ContentPanel::earlier_clicked ()
 void
 ContentPanel::later_clicked ()
 {
-       ContentList sel = selected ();
+       auto sel = selected ();
        if (sel.size() == 1) {
                _film->move_content_later (sel.front ());
                check_selection ();
@@ -627,7 +627,7 @@ ContentPanel::later_clicked ()
 void
 ContentPanel::set_selection (weak_ptr<Content> wc)
 {
-       ContentList content = _film->content ();
+       auto content = _film->content ();
        for (size_t i = 0; i < content.size(); ++i) {
                if (content[i] == wc.lock ()) {
                        _content->SetItemState (i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
@@ -642,7 +642,7 @@ ContentPanel::set_selection (ContentList cl)
 {
        _no_check_selection = true;
 
-       ContentList content = _film->content ();
+       auto content = _film->content ();
        for (size_t i = 0; i < content.size(); ++i) {
                if (find(cl.begin(), cl.end(), content[i]) != cl.end()) {
                        _content->SetItemState (i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
@@ -682,10 +682,10 @@ ContentPanel::setup ()
                return;
        }
 
-       ContentList content = _film->content ();
+       auto content = _film->content ();
 
-       Content* selected_content = 0;
-       int const s = _content->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+       Content* selected_content = nullptr;
+       auto const s = _content->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
        if (s != -1) {
                wxListItem item;
                item.SetId (s);
@@ -700,11 +700,11 @@ ContentPanel::setup ()
                int const t = _content->GetItemCount ();
                bool const valid = i->paths_valid ();
 
-               shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent> (i);
+               auto dcp = dynamic_pointer_cast<DCPContent> (i);
                bool const needs_kdm = dcp && dcp->needs_kdm ();
                bool const needs_assets = dcp && dcp->needs_assets ();
 
-               wxString s = std_to_wx (i->summary ());
+               auto s = std_to_wx (i->summary ());
 
                if (!valid) {
                        s = _("MISSING: ") + s;
@@ -748,7 +748,7 @@ ContentPanel::files_dropped (wxDropFilesEvent& event)
                return;
        }
 
-       wxString* paths = event.GetFiles ();
+       auto paths = event.GetFiles ();
        list<boost::filesystem::path> path_list;
        for (int i = 0; i < event.GetNumberOfFiles(); i++) {
                path_list.push_back (wx_to_std (paths[i]));
index 5d941301bcb75865b8c2b545aa5bd46d20d22d4c..8b87595b493292aaa3364f20f67ca723765d30c8 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -102,7 +102,7 @@ DCPPanel::DCPPanel (wxNotebook* n, shared_ptr<Film> film, weak_ptr<FilmViewer> v
        _encrypted = new CheckBox (_panel, _("Encrypted"));
 
         wxClientDC dc (_panel);
-        wxSize size = dc.GetTextExtent (wxT ("GGGGGGGG..."));
+        auto size = dc.GetTextExtent (wxT ("GGGGGGGG..."));
         size.SetHeight (-1);
 
        _reels_label = create_label (_panel, _("Reels"), true);
@@ -205,7 +205,7 @@ DCPPanel::add_to_grid ()
        _grid->Add (_standard, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
        ++r;
 
-       wxBoxSizer* extra = new wxBoxSizer (wxHORIZONTAL);
+       auto extra = new wxBoxSizer (wxHORIZONTAL);
        extra->Add (_markers, 1, wxRIGHT, DCPOMATIC_SIZER_X_GAP);
        extra->Add (_metadata, 1, wxRIGHT, DCPOMATIC_SIZER_X_GAP);
        _grid->Add (extra, wxGBPosition(r, 0), wxGBSpan(1, 2));
@@ -523,19 +523,19 @@ 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 = 0;
+               _audio_dialog = nullptr;
        }
        if (_markers_dialog) {
                _markers_dialog->Destroy ();
-               _markers_dialog = 0;
+               _markers_dialog = nullptr;
        }
        if (_interop_metadata_dialog) {
                _interop_metadata_dialog->Destroy ();
-               _interop_metadata_dialog = 0;
+               _interop_metadata_dialog = nullptr;
        }
        if (_smpte_metadata_dialog) {
                _smpte_metadata_dialog->Destroy ();
-               _smpte_metadata_dialog = 0;
+               _smpte_metadata_dialog = nullptr;
        }
 
        _film = film;
@@ -634,7 +634,7 @@ DCPPanel::edit_isdcf_button_clicked ()
                return;
        }
 
-       ISDCFMetadataDialog* d = new ISDCFMetadataDialog (_panel, _film->isdcf_metadata (), _film->three_d ());
+       auto d = new ISDCFMetadataDialog (_panel, _film->isdcf_metadata (), _film->three_d ());
        d->ShowModal ();
        _film->set_isdcf_metadata (d->isdcf_metadata ());
        d->Destroy ();
@@ -707,8 +707,8 @@ DCPPanel::setup_frame_rate_widget ()
 wxPanel *
 DCPPanel::make_video_panel ()
 {
-       wxPanel* panel = new wxPanel (_notebook);
-       wxSizer* sizer = new wxBoxSizer (wxVERTICAL);
+       auto panel = new wxPanel (_notebook);
+       auto sizer = new wxBoxSizer (wxVERTICAL);
        _video_grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
        sizer->Add (_video_grid, 0, wxALL, 8);
        panel->SetSizer (sizer);
@@ -796,7 +796,7 @@ DCPPanel::add_video_panel_to_grid ()
        ++r;
 
        add_label_to_sizer (_video_grid, _j2k_bandwidth_label, true, wxGBPosition (r, 0));
-       wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
+       auto s = new wxBoxSizer (wxHORIZONTAL);
        s->Add (_j2k_bandwidth, 0, wxALIGN_CENTER_VERTICAL);
        add_label_to_sizer (s, _mbits_label, false, 0, wxALIGN_CENTER_VERTICAL);
        _video_grid->Add (s, wxGBPosition(r, 1), wxDefaultSpan, wxEXPAND);
@@ -822,7 +822,7 @@ DCPPanel::minimum_allowed_audio_channels () const
 wxPanel *
 DCPPanel::make_audio_panel ()
 {
-       wxPanel* panel = new wxPanel (_notebook);
+       auto panel = new wxPanel (_notebook);
        _audio_panel_sizer = new wxBoxSizer (wxVERTICAL);
        _audio_grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
        _audio_panel_sizer->Add (_audio_grid, 0, wxALL, 8);
@@ -878,7 +878,7 @@ DCPPanel::audio_processor_changed ()
                return;
        }
 
-       string const s = string_client_data (_audio_processor->GetClientObject (_audio_processor->GetSelection ()));
+       auto const s = string_client_data (_audio_processor->GetClientObject (_audio_processor->GetSelection ()));
        _film->set_audio_processor (AudioProcessor::from_id (s));
 }
 
@@ -894,7 +894,7 @@ DCPPanel::show_audio_clicked ()
                _audio_dialog = 0;
        }
 
-       AudioDialog* d = new AudioDialog (_panel, _film, _viewer);
+       auto d = new AudioDialog (_panel, _film, _viewer);
        d->Show ();
 }
 
index 3386b2700c522c7047c4bb0e0c738473cf1b6303..8b6d0961ba74a0f91b3e59d11c3b309a9ade9bc5 100644 (file)
@@ -80,7 +80,7 @@ add_label_to_sizer (wxSizer* s, wxWindow* p, wxString t, bool left, int prop, in
                flags |= wxALIGN_RIGHT;
        }
 #endif
-       wxStaticText* m = create_label (p, t, left);
+       auto m = create_label (p, t, left);
        s->Add (m, prop, flags, 6);
        return m;
 }
@@ -110,7 +110,7 @@ add_label_to_sizer (wxGridBagSizer* s, wxWindow* p, wxString t, bool left, wxGBP
                flags |= wxALIGN_RIGHT;
        }
 #endif
-       wxStaticText* m = create_label (p, t, left);
+       auto m = create_label (p, t, left);
        s->Add (m, pos, span, flags);
        return m;
 }
@@ -140,7 +140,7 @@ add_label_to_sizer (wxGridBagSizer* s, wxStaticText* t, bool, wxGBPosition pos,
 void
 error_dialog (wxWindow* parent, wxString m, optional<wxString> e)
 {
-       wxMessageDialog* d = new wxMessageDialog (parent, m, _("DCP-o-matic"), wxOK | wxICON_ERROR);
+       auto d = new wxMessageDialog (parent, m, _("DCP-o-matic"), wxOK | wxICON_ERROR);
        if (e) {
                wxString em = *e;
                em[0] = wxToupper (em[0]);
@@ -157,7 +157,7 @@ error_dialog (wxWindow* parent, wxString m, optional<wxString> e)
 void
 message_dialog (wxWindow* parent, wxString m)
 {
-       wxMessageDialog* d = new wxMessageDialog (parent, m, _("DCP-o-matic"), wxOK | wxICON_INFORMATION);
+       auto d = new wxMessageDialog (parent, m, _("DCP-o-matic"), wxOK | wxICON_INFORMATION);
        d->ShowModal ();
        d->Destroy ();
 }
@@ -253,7 +253,7 @@ checked_set (wxChoice* widget, int value)
 void
 checked_set (wxChoice* widget, string value)
 {
-       wxClientData* o = 0;
+       wxClientData* o = nullptr;
        if (widget->GetSelection() != -1) {
                o = widget->GetClientObject (widget->GetSelection ());
        }
@@ -285,8 +285,8 @@ checked_set (wxChoice* widget, vector<pair<string, string> > items)
        }
 
        widget->Clear ();
-       for (vector<pair<string, string> >::const_iterator i = items.begin(); i != items.end(); ++i) {
-               widget->Append (std_to_wx (i->first), new wxStringClientData (std_to_wx (i->second)));
+       for (auto i: items) {
+               widget->Append (std_to_wx(i.first), new wxStringClientData(std_to_wx(i.second)));
        }
 }
 
@@ -351,15 +351,15 @@ dcpomatic_setup_i18n ()
 {
        int language = wxLANGUAGE_DEFAULT;
 
-       boost::optional<string> config_lang = Config::instance()->language ();
+       auto config_lang = Config::instance()->language ();
        if (config_lang && !config_lang->empty ()) {
-               wxLanguageInfo const * li = wxLocale::FindLanguageInfo (std_to_wx (config_lang.get ()));
+               auto const li = wxLocale::FindLanguageInfo (std_to_wx (config_lang.get ()));
                if (li) {
                        language = li->Language;
                }
        }
 
-       wxLocale* locale = 0;
+       wxLocale* locale = nullptr;
        if (wxLocale::IsAvailable (language)) {
                locale = new wxLocale (language, wxLOCALE_LOAD_DEFAULT);
 
@@ -418,7 +418,7 @@ wx_get (wxSpinCtrlDouble* w)
 wxString
 context_translation (wxString s)
 {
-       wxString t = wxGetTranslation (s);
+       auto t = wxGetTranslation (s);
        if (t == s) {
                /* No translation; strip the context */
                int c = t.Find (wxT ("|"));
@@ -433,7 +433,7 @@ context_translation (wxString s)
 wxString
 time_to_timecode (DCPTime t, double fps)
 {
-       double w = t.seconds ();
+       auto w = t.seconds ();
        int const h = (w / 3600);
        w -= h * 3600;
        int const m = (w / 60);
@@ -470,7 +470,7 @@ setup_audio_channels_choice (wxChoice* choice, int minimum)
 wxSplashScreen *
 maybe_show_splash ()
 {
-       wxSplashScreen* splash = 0;
+       wxSplashScreen* splash = nullptr;
        try {
                wxBitmap bitmap;
                if (bitmap.LoadFile(bitmap_path("splash"), wxBITMAP_TYPE_PNG)) {
@@ -512,7 +512,7 @@ calculate_mark_interval (double mark_interval)
 bool
 display_progress (wxString title, wxString task)
 {
-       JobManager* jm = JobManager::instance ();
+       auto jm = JobManager::instance ();
 
        wxProgressDialog progress (title, task, 100, 0, wxPD_CAN_ABORT);
 
@@ -597,7 +597,7 @@ wxSize
 small_button_size (wxWindow* parent, wxString text)
 {
        wxClientDC dc (parent);
-       wxSize size = dc.GetTextExtent (text);
+       auto size = dc.GetTextExtent (text);
        size.SetHeight (-1);
        size.IncBy (24, 0);
        return size;