From 062eb55250db1f081f718650952a1ca22a6c860a Mon Sep 17 00:00:00 2001 From: Doug Walker Date: Thu, 19 Mar 2026 17:43:00 -0400 Subject: [PATCH] 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.