From 95cb3dbda662e6d7731d9b04842d839dcd1d9b01 Mon Sep 17 00:00:00 2001 From: Murray Stevenson <50844517+murraystevenson@users.noreply.github.com> Date: Tue, 16 Dec 2025 17:45:31 -0800 Subject: [PATCH] EditScopeAlgo : Sanitise '.' in attribute names --- Changes.md | 1 + python/GafferSceneTest/EditScopeAlgoTest.py | 18 ++++++++++++++++++ src/GafferScene/EditScopeAlgo.cpp | 6 ++++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Changes.md b/Changes.md index 81306905a85..da93f6890f4 100644 --- a/Changes.md +++ b/Changes.md @@ -13,6 +13,7 @@ Fixes ----- - SceneInspector : Fixed cell background colour updates when changing EditScope. +- AttributeEditor, SceneInspector : Fixed bug preventing edits from being created in an EditScope for attributes with `.` characters in their name. 1.6.7.0 (relative to 1.6.6.1) ======= diff --git a/python/GafferSceneTest/EditScopeAlgoTest.py b/python/GafferSceneTest/EditScopeAlgoTest.py index 9c6216afb4b..d332a6d12ea 100644 --- a/python/GafferSceneTest/EditScopeAlgoTest.py +++ b/python/GafferSceneTest/EditScopeAlgoTest.py @@ -1035,6 +1035,24 @@ def testAttributeEditFromDefaultValueMetadata( self ) : self.assertIsNotNone( GafferScene.EditScopeAlgo.acquireAttributeEdit( editScope, "/sphere", "test:bogus" ) ) self.assertNotEqual( editScope.keys(), emptyKeys ) + def testAttributeEditNameSanitisation( self ) : + + sphere = GafferScene.Sphere() + + customAttributes = GafferScene.CustomAttributes() + customAttributes["in"].setInput( sphere["out"] ) + customAttributes["attributes"].addMember( "test:fancy.attribute", 123 ) + + editScope = Gaffer.EditScope() + editScope.setup( customAttributes["out"] ) + editScope["in"].setInput( customAttributes["out"] ) + + edit = GafferScene.EditScopeAlgo.acquireAttributeEdit( editScope, "/sphere", "test:fancy.attribute" ) + self.assertIsInstance( edit, Gaffer.TweakPlug ) + edit["enabled"].setValue( True ) + edit["value"].setValue( 456 ) + self.assertEqual( editScope["out"].attributes( "/sphere" )["test:fancy.attribute"].value, 456 ) + def testProcessorNames( self ) : plane = GafferScene.Plane() diff --git a/src/GafferScene/EditScopeAlgo.cpp b/src/GafferScene/EditScopeAlgo.cpp index d76bc43be8c..8f90819361f 100644 --- a/src/GafferScene/EditScopeAlgo.cpp +++ b/src/GafferScene/EditScopeAlgo.cpp @@ -804,7 +804,8 @@ TweakPlug *GafferScene::EditScopeAlgo::acquireAttributeEdit( Gaffer::EditScope * // Find cell for attribute - std::string columnName = boost::replace_all_copy( attribute, ":", "_" ); + std::string columnName; + boost::replace_copy_if( attribute, std::back_inserter( columnName ), boost::is_any_of( ".:" ), '_' ); if( auto *cell = row->cellsPlug()->getChild( columnName ) ) { return cell->valuePlug(); @@ -867,7 +868,8 @@ const Gaffer::GraphComponent *GafferScene::EditScopeAlgo::attributeEditReadOnlyR return reason; } - std::string columnName = boost::replace_all_copy( attribute, ":", "_" ); + std::string columnName; + boost::replace_copy_if( attribute, std::back_inserter( columnName ), boost::is_any_of( ".:" ), '_' ); if( auto *cell = row->cellsPlug()->getChild( columnName ) ) { if( MetadataAlgo::getReadOnly( cell ) )