From: Carl Hetherington Date: Thu, 28 Apr 2022 20:12:54 +0000 (+0200) Subject: Fix (I think) some strange situations where ::get() on dialogs X-Git-Tag: v2.16.10~11 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=54141c7a9504e289d41af997067ca6b78a1d4b0a Fix (I think) some strange situations where ::get() on dialogs used by EditableList would return something that wasn't a optional<> but would then get implicitly cast to one. Now we have a static_assert to check that the type is what we expect. --- diff --git a/src/tools/dcpomatic_combiner.cc b/src/tools/dcpomatic_combiner.cc index 40587e23a..4532b0429 100644 --- a/src/tools/dcpomatic_combiner.cc +++ b/src/tools/dcpomatic_combiner.cc @@ -65,7 +65,7 @@ public: } - boost::filesystem::path get () const + optional get () const { return boost::filesystem::path(wx_to_std(GetPath())); } diff --git a/src/wx/content_version_dialog.cc b/src/wx/content_version_dialog.cc index 37c9cd416..876f43838 100644 --- a/src/wx/content_version_dialog.cc +++ b/src/wx/content_version_dialog.cc @@ -24,6 +24,7 @@ using std::string; +using boost::optional; ContentVersionDialog::ContentVersionDialog (wxWindow* parent) @@ -46,7 +47,7 @@ ContentVersionDialog::set (string r) } -string +optional ContentVersionDialog::get () const { return wx_to_std(_version->GetValue()); diff --git a/src/wx/content_version_dialog.h b/src/wx/content_version_dialog.h index 8f375984d..8407c0475 100644 --- a/src/wx/content_version_dialog.h +++ b/src/wx/content_version_dialog.h @@ -30,7 +30,7 @@ public: ContentVersionDialog (wxWindow* parent); void set (std::string); - std::string get () const; + boost::optional get () const; private: wxTextCtrl* _version; diff --git a/src/wx/editable_list.h b/src/wx/editable_list.h index 56c3a9463..e82c4f91c 100644 --- a/src/wx/editable_list.h +++ b/src/wx/editable_list.h @@ -210,7 +210,8 @@ private: S* dialog = new S (this); if (dialog->ShowModal() == wxID_OK) { - boost::optional const v = dialog->get (); + auto const v = dialog->get (); + static_assert(std::is_same::type, boost::optional>::value, "get() must return boost::optional"); if (v) { add_to_control (v.get ()); std::vector all = _get (); @@ -235,7 +236,8 @@ private: S* dialog = new S (this); dialog->set (all[item]); if (dialog->ShowModal() == wxID_OK) { - boost::optional const v = dialog->get (); + auto const v = dialog->get (); + static_assert(std::is_same::type, boost::optional>::value, "get() must return boost::optional"); if (!v) { return; } diff --git a/src/wx/rating_dialog.cc b/src/wx/rating_dialog.cc index 9c75f0d4c..691a7d16d 100644 --- a/src/wx/rating_dialog.cc +++ b/src/wx/rating_dialog.cc @@ -92,7 +92,7 @@ RatingDialog::set (dcp::Rating rating) } -dcp::Rating +optional RatingDialog::get () const { return _active_page->get(); diff --git a/src/wx/rating_dialog.h b/src/wx/rating_dialog.h index 66a93305a..97a56f52e 100644 --- a/src/wx/rating_dialog.h +++ b/src/wx/rating_dialog.h @@ -90,7 +90,7 @@ public: RatingDialog (wxWindow* parent); void set (dcp::Rating r); - dcp::Rating get () const; + boost::optional get () const; private: void setup_sensitivity (bool ok_valid);