Skip to content

Commit 044f66b

Browse files
authored
Adsk Contrib - Hue curve python binding was not copying all parameters (#2276)
* Fix bug in hue curve python binding Signed-off-by: Doug Walker <doug.walker@autodesk.com> * Pointer check improvement Signed-off-by: Doug Walker <doug.walker@autodesk.com> * Dangling reference fix Signed-off-by: Doug Walker <doug.walker@autodesk.com> --------- Signed-off-by: Doug Walker <doug.walker@autodesk.com>
1 parent 75bb9d0 commit 044f66b

4 files changed

Lines changed: 34 additions & 8 deletions

File tree

src/OpenColorIO/Config.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ class Config::Impl
798798
}
799799

800800
const ViewVec & views = searchShared ? m_sharedViews : iter->second.m_views;
801-
const auto & viewIt = FindView(views, view);
801+
const auto viewIt = FindView(views, view);
802802

803803
if (viewIt != views.end())
804804
{

src/OpenColorIO/fileformats/ctf/CTFReaderHelper.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -856,25 +856,25 @@ void CTFReaderInfoElt::end()
856856

857857
//////////////////////////////////////////////////////////
858858

859-
void CTFReaderDescElt::start(const char ** atttributes )
859+
void CTFReaderDescElt::start(const char ** atts )
860860
{
861861
m_desc = {};
862862
m_language = {};
863863

864-
const char ** attr = atttributes;
865-
while (*attr)
864+
unsigned i = 0;
865+
while (atts[i] && *atts[i])
866866
{
867-
if (0 == Platform::Strcasecmp(ATTR_LANGUAGE, *attr))
867+
if (0 == Platform::Strcasecmp(ATTR_LANGUAGE, *atts))
868868
{
869-
if (!attr || !(attr + 1))
869+
if (!atts[i + 1] || !*atts[i + 1])
870870
{
871871
throwMessage("Attribute 'language' does not have a value.");
872872
}
873873

874-
m_language = *(attr + 1);
874+
m_language = atts[i + 1];
875875
}
876876

877-
attr += 2;
877+
i += 2;
878878
}
879879
}
880880

src/bindings/python/PyGradingData.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@ using GradingControlPointIterator = PyIterator<GradingBSplineCurveRcPtr, IT_CONT
2121

2222
void CopyGradingBSpline(GradingBSplineCurveRcPtr to, const ConstGradingBSplineCurveRcPtr from)
2323
{
24+
to->setSplineType(from->getSplineType());
25+
2426
const size_t numPt = from->getNumControlPoints();
2527
to->setNumControlPoints(numPt);
2628
for (size_t pt = 0; pt < numPt; ++pt)
2729
{
2830
to->getControlPoint(pt) = from->getControlPoint(pt);
31+
to->setSlope(pt, from->getSlope(pt));
2932
}
3033
}
3134

tests/python/GradingDataTest.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,29 @@ def test_huecurve(self):
368368
assertEqualBSpline(self, hcrv.lum_sat, ls)
369369
self.assertEqual(hcrv.lum_sat, ls)
370370

371+
# Check that setting the hue curve preserves the spline type.
372+
hcrv.hue_sat = ls
373+
ls2 = hcrv.hue_sat
374+
# Spline type is now different than what hue_sat normally uses (PERIODIC_1_B_SPLINE).
375+
self.assertEqual(ls2.getSplineType(), OCIO.HORIZONTAL1_B_SPLINE)
376+
self.assertEqual(hcrv.hue_sat, ls)
377+
self.assertEqual(ls2, ls)
378+
379+
# Check that setting the hue curve preserves the slopes.
380+
self.assertEqual(ls.slopesAreDefault(), True)
381+
slopes = ls.getSlopes()
382+
slopes[1] = 0.5
383+
ls.setSlopes(slopes)
384+
self.assertEqual(ls.slopesAreDefault(), False)
385+
hcrv.hue_sat = ls
386+
ls2 = hcrv.hue_sat
387+
self.assertEqual(ls2.slopesAreDefault(), False)
388+
slopes2 = ls2.getSlopes()
389+
self.assertEqual(slopes2[1], 0.5)
390+
self.assertEqual(slopes2, slopes)
391+
self.assertEqual(hcrv.hue_sat, ls)
392+
self.assertEqual(ls2, ls)
393+
371394
def test_rgbmsw(self):
372395
"""
373396
Test the GradingRGBMSW struct.

0 commit comments

Comments
 (0)