Skip to content

Commit

Permalink
StringPlug : Remove deprecated precomputedHash argument from `getVa…
Browse files Browse the repository at this point in the history
…lue()`
  • Loading branch information
johnhaddon committed Sep 20, 2023
1 parent ac5c33b commit b04ec0b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 15 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Breaking Changes

- Dispatcher : Removed `createMatching()` method.
- Process : Removed non-const variant of the `handleException()` method.
- StringPlug : Remove deprecated `precomputedHash` argument from `getValue()` method.

1.3.x.x (relative to 1.3.3.0)
=======
Expand Down
6 changes: 2 additions & 4 deletions include/Gaffer/StringPlug.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,8 @@ class GAFFER_API StringPlug : public ValuePlug
/// > (which would be `\` on Windows).
/// \undoable
void setValue( const std::filesystem::path &value );
/// Returns the value. The `precomputedHash` argument is deprecated, and
/// will be removed in a future release.
/// \todo Remove `precomputedHash` argument.
std::string getValue( const IECore::MurmurHash *precomputedHash = nullptr ) const;
/// Returns the value.
std::string getValue() const;

void setFrom( const ValuePlug *other ) override;

Expand Down
6 changes: 0 additions & 6 deletions python/GafferTest/StringPlugTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,11 @@ def testSubstitutionsFromExpressionInput( self ) :

self.assertEqual( s["substitionsOn"]["out"].getValue(), "test.1.exr" )
substitutionsOnHash1 = s["substitionsOn"]["out"].hash()
self.assertEqual( s["substitionsOn"]["out"].getValue( _precomputedHash = substitutionsOnHash1 ), "test.1.exr" )

# We should get sequences out of the non-substituting node.

self.assertEqual( s["substitionsOff"]["out"].getValue(), "test.#.exr" )
substitutionsOffHash1 = s["substitionsOff"]["out"].hash()
self.assertEqual( s["substitionsOff"]["out"].getValue( _precomputedHash = substitutionsOffHash1 ), "test.#.exr" )
self.assertNotEqual( substitutionsOnHash1, substitutionsOffHash1 )

# We shouldn't get frame numbers out of the third node, because the
Expand All @@ -320,7 +318,6 @@ def testSubstitutionsFromExpressionInput( self ) :

self.assertEqual( s["substitionsOnIndirectly"]["out"].getValue(), "test.#.exr" )
substitionsOnIndirectlyHash1 = s["substitionsOnIndirectly"]["out"].hash()
self.assertEqual( s["substitionsOnIndirectly"]["out"].getValue( _precomputedHash = substitionsOnIndirectlyHash1 ), "test.#.exr" )

# Frame 2
#########
Expand All @@ -339,23 +336,20 @@ def testSubstitutionsFromExpressionInput( self ) :

self.assertEqual( s["substitionsOn"]["out"].getValue(), "test.2.exr" )
substitutionsOnHash2 = s["substitionsOn"]["out"].hash()
self.assertEqual( s["substitionsOn"]["out"].getValue( _precomputedHash = substitutionsOnHash2 ), "test.2.exr" )
self.assertNotEqual( substitutionsOnHash2, substitutionsOnHash1 )

# We should still get sequences out of the non-substituting node,
# and it should have the same output hash as it had on frame 1.

self.assertEqual( s["substitionsOff"]["out"].getValue(), "test.#.exr" )
substitutionsOffHash2 = s["substitionsOff"]["out"].hash()
self.assertEqual( s["substitionsOff"]["out"].getValue( _precomputedHash = substitutionsOffHash2 ), "test.#.exr" )
self.assertEqual( substitutionsOffHash1, substitutionsOffHash2 )
self.assertNotEqual( substitutionsOnHash2, substitutionsOffHash2 )

# The third node should still be non-substituting.

self.assertEqual( s["substitionsOnIndirectly"]["out"].getValue(), "test.#.exr" )
substitionsOnIndirectlyHash2 = s["substitionsOnIndirectly"]["out"].hash()
self.assertEqual( s["substitionsOnIndirectly"]["out"].getValue( _precomputedHash = substitionsOnIndirectlyHash2 ), "test.#.exr" )
self.assertEqual( substitionsOnIndirectlyHash2, substitionsOnIndirectlyHash1 )

def testHashUsesValue( self ) :
Expand Down
4 changes: 2 additions & 2 deletions src/Gaffer/StringPlug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ void StringPlug::setValue( const std::filesystem::path &value )
setValue( value.generic_string() );
}

std::string StringPlug::getValue( const IECore::MurmurHash *precomputedHash ) const
std::string StringPlug::getValue() const
{
ConstStringDataPtr s = getObjectValue<StringData>( precomputedHash );
ConstStringDataPtr s = getObjectValue<StringData>();

const bool performSubstitutions =
m_substitutions &&
Expand Down
6 changes: 3 additions & 3 deletions src/GafferModule/StringPlugBinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ void setPathValue( StringPlug *plug, const std::filesystem::path &value )
plug->setValue( value );
}

std::string getValue( const StringPlug *plug, const IECore::MurmurHash *precomputedHash )
std::string getValue( const StringPlug *plug )
{
// Must release GIL in case computation spawns threads which need
// to reenter Python.
IECorePython::ScopedGILRelease r;
return plug->getValue( precomputedHash );
return plug->getValue();
}

std::string substitutionsRepr( unsigned substitutions )
Expand Down Expand Up @@ -161,7 +161,7 @@ void GafferModule::bindStringPlug()
// Must be registered before string-based `setValue()`, to give it weaker overloading precedence.
.def( "setValue", &setPathValue )
.def( "setValue", &setValue )
.def( "getValue", &getValue, ( boost::python::arg( "_precomputedHash" ) = object() ) )
.def( "getValue", &getValue )
;

s.attr( "ValueType" ) = boost::python::object( boost::python::handle<>( boost::python::borrowed( &PyUnicode_Type ) ) );
Expand Down

0 comments on commit b04ec0b

Please sign in to comment.