Fix mistake in a7f61a15 causing bad_alloc exceptions during tests.
authorCarl Hetherington <cth@carlh.net>
Thu, 23 Dec 2021 17:14:51 +0000 (18:14 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 23 Dec 2021 17:14:51 +0000 (18:14 +0100)
src/lib/ratio.cc
test/ratio_test.cc

index aa222b11610152b11a4590fe722dcca6bb7be07f..5f1a3aa63d31a98a9b6afa441e86d84140b6f455 100644 (file)
@@ -39,6 +39,9 @@ vector<Ratio> Ratio::_ratios;
 void
 Ratio::setup_ratios ()
 {
+       /* This must only be called once as we rely on the addresses of objects in _ratios staying the same */
+       DCPOMATIC_ASSERT (_ratios.empty());
+
        _ratios.push_back (Ratio(float(1290) / 1080, "119", _("1.19"),              {},                      "119"));
        _ratios.push_back (Ratio(float(1440) / 1080, "133", _("1.33 (4:3)"),        {},                      "133"));
        _ratios.push_back (Ratio(float(1485) / 1080, "138", _("1.38 (Academy)"),    {},                      "137"));
index c922301c25f149bb3e552daccd6cad9ac6308e80..a21859049823cb9cc07db48ed223b4d0c53a8623 100644 (file)
@@ -34,8 +34,6 @@ using std::ostream;
 
 BOOST_AUTO_TEST_CASE (ratio_test)
 {
-       Ratio::setup_ratios ();
-
        Ratio const * r = Ratio::from_id ("119");
        BOOST_CHECK (r);
        BOOST_CHECK_EQUAL (fit_ratio_within (r->ratio(), dcp::Size (2048, 1080)), dcp::Size (1290, 1080));
@@ -72,8 +70,6 @@ BOOST_AUTO_TEST_CASE (ratio_test)
 
 BOOST_AUTO_TEST_CASE (ratios_use_same_pointers_test)
 {
-       Ratio::setup_ratios ();
-
        auto const test = Ratio::from_id ("119");
        BOOST_CHECK_EQUAL (test, Ratio::from_id("119"));
 }