From 062eb55250db1f081f718650952a1ca22a6c860a Mon Sep 17 00:00:00 2001 From: Doug Walker Date: Thu, 19 Mar 2026 17:43:00 -0400 Subject: [PATCH 1/3] Fix bug in hue curve python binding Signed-off-by: Doug Walker --- .../fileformats/ctf/CTFReaderHelper.cpp | 4 ++-- src/bindings/python/PyGradingData.cpp | 3 +++ tests/python/GradingDataTest.py | 23 +++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/OpenColorIO/fileformats/ctf/CTFReaderHelper.cpp b/src/OpenColorIO/fileformats/ctf/CTFReaderHelper.cpp index f8ecd7eb6e..00ef9ac01b 100644 --- a/src/OpenColorIO/fileformats/ctf/CTFReaderHelper.cpp +++ b/src/OpenColorIO/fileformats/ctf/CTFReaderHelper.cpp @@ -862,11 +862,11 @@ void CTFReaderDescElt::start(const char ** atttributes ) m_language = {}; const char ** attr = atttributes; - while (*attr) + while (attr && *attr) { if (0 == Platform::Strcasecmp(ATTR_LANGUAGE, *attr)) { - if (!attr || !(attr + 1)) + if (!(attr + 1) || !*(attr + 1)) { throwMessage("Attribute 'language' does not have a value."); } diff --git a/src/bindings/python/PyGradingData.cpp b/src/bindings/python/PyGradingData.cpp index a1a093d7b3..c34179cf4e 100644 --- a/src/bindings/python/PyGradingData.cpp +++ b/src/bindings/python/PyGradingData.cpp @@ -21,11 +21,14 @@ using GradingControlPointIterator = PyIteratorsetSplineType(from->getSplineType()); + const size_t numPt = from->getNumControlPoints(); to->setNumControlPoints(numPt); for (size_t pt = 0; pt < numPt; ++pt) { to->getControlPoint(pt) = from->getControlPoint(pt); + to->setSlope(pt, from->getSlope(pt)); } } diff --git a/tests/python/GradingDataTest.py b/tests/python/GradingDataTest.py index 39cd8ba5cc..34abd89fff 100644 --- a/tests/python/GradingDataTest.py +++ b/tests/python/GradingDataTest.py @@ -368,6 +368,29 @@ def test_huecurve(self): assertEqualBSpline(self, hcrv.lum_sat, ls) self.assertEqual(hcrv.lum_sat, ls) + # Check that setting the hue curve preserves the spline type. + hcrv.hue_sat = ls + ls2 = hcrv.hue_sat + # Spline type is now different than what hue_sat normally uses (PERIODIC_1_B_SPLINE). + self.assertEqual(ls2.getSplineType(), OCIO.HORIZONTAL1_B_SPLINE) + self.assertEqual(hcrv.hue_sat, ls) + self.assertEqual(ls2, ls) + + # Check that setting the hue curve preserves the slopes. + self.assertEqual(ls.slopesAreDefault(), True) + slopes = ls.getSlopes() + slopes[1] = 0.5 + ls.setSlopes(slopes) + self.assertEqual(ls.slopesAreDefault(), False) + hcrv.hue_sat = ls + ls2 = hcrv.hue_sat + self.assertEqual(ls2.slopesAreDefault(), False) + slopes2 = ls2.getSlopes() + self.assertEqual(slopes2[1], 0.5) + self.assertEqual(slopes2, slopes) + self.assertEqual(hcrv.hue_sat, ls) + self.assertEqual(ls2, ls) + def test_rgbmsw(self): """ Test the GradingRGBMSW struct. From 6315d88d30196479468027ded51b481a9d8b0de1 Mon Sep 17 00:00:00 2001 From: Doug Walker Date: Fri, 27 Mar 2026 16:51:48 -0400 Subject: [PATCH 2/3] Pointer check improvement Signed-off-by: Doug Walker --- .../fileformats/ctf/CTFReaderHelper.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/OpenColorIO/fileformats/ctf/CTFReaderHelper.cpp b/src/OpenColorIO/fileformats/ctf/CTFReaderHelper.cpp index 00ef9ac01b..1bf162db35 100644 --- a/src/OpenColorIO/fileformats/ctf/CTFReaderHelper.cpp +++ b/src/OpenColorIO/fileformats/ctf/CTFReaderHelper.cpp @@ -856,25 +856,25 @@ void CTFReaderInfoElt::end() ////////////////////////////////////////////////////////// -void CTFReaderDescElt::start(const char ** atttributes ) +void CTFReaderDescElt::start(const char ** atts ) { m_desc = {}; m_language = {}; - const char ** attr = atttributes; - while (attr && *attr) + unsigned i = 0; + while (atts[i] && *atts[i]) { - if (0 == Platform::Strcasecmp(ATTR_LANGUAGE, *attr)) + if (0 == Platform::Strcasecmp(ATTR_LANGUAGE, *atts)) { - if (!(attr + 1) || !*(attr + 1)) + if (!atts[i + 1] || !*atts[i + 1]) { throwMessage("Attribute 'language' does not have a value."); } - m_language = *(attr + 1); + m_language = atts[i + 1]; } - attr += 2; + i += 2; } } From 0667d33e6ebe34d8a914bed2809d11f1e8231b87 Mon Sep 17 00:00:00 2001 From: Doug Walker Date: Fri, 3 Apr 2026 00:01:30 -0400 Subject: [PATCH 3/3] Dangling reference fix Signed-off-by: Doug Walker --- src/OpenColorIO/Config.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenColorIO/Config.cpp b/src/OpenColorIO/Config.cpp index 2ac0572443..d4d5fbe7fa 100644 --- a/src/OpenColorIO/Config.cpp +++ b/src/OpenColorIO/Config.cpp @@ -798,7 +798,7 @@ class Config::Impl } const ViewVec & views = searchShared ? m_sharedViews : iter->second.m_views; - const auto & viewIt = FindView(views, view); + const auto viewIt = FindView(views, view); if (viewIt != views.end()) {