Skip to content

Commit c7538a7

Browse files
committed
LinkedScene : Fix incorrect linkLocations attribute value
The old code was incorrectly appending the target's location to the `linkLocations`. The `linkLocations` are expected to hold the locations in the current LinkedScene that contain links to other files. These paths are expected to exist in the LinkedScene itself. Everything worked fine if the target location was set to the ROOT, but if it was targeting an internal location, that would be appended which would result in an invalid path. The cause for that bug was that we were updating `m_linkedScene`, which is used to compute LinkedScene::path(), but not updating the `m_rootLinkDepth` property, which is also used to compute the path, by stripping out part of it based on the depth of the link. For `linkLocations`, that depth should generally be expected to completely remove any contributions from `m_linkedScene`, since this is the location where the link is being created, and therefore the `m_rootLinkDepth` will match the length of the path inside the target linked scene that we are linking to. Note that existing saved `lscc` files have the attribute baked in, and are therefore not fixed by this commit. A new export is necessary in order to fix it.
1 parent 43d779d commit c7538a7

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

Changes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
10.4.x.x (relative to 10.4.10.1)
22
========
33

4+
Fixes
5+
-----
6+
7+
- LinkedScene : Fixed bug where `linkLocations` attribute was baked incorrectly if the link target location wasn't the ROOT
8+
- This in turn caused LinkedScene::setNames() and LinkedScene::readSet() to error
9+
410
10.4.10.1 (relative to 10.4.10.0)
511
========
612

src/IECoreScene/LinkedScene.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,7 @@ void LinkedScene::writeAttribute( const Name &name, const Object *attribute, dou
700700
{
701701
throw Exception( "Trying to store a broken link!" );
702702
}
703+
m_rootLinkDepth = linkDepth;
703704

704705
// check for child name clashes:
705706
NameList mainSceneChildren;

test/IECoreScene/LinkedSceneTest.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,26 +1094,41 @@ def testCanReadSetNamesAndMembersOfLinkedScene( self ) :
10941094

10951095
r = IECoreScene.SceneCache( sceneFile, IECore.IndexedIO.OpenMode.Read )
10961096
A = r.child( "A" )
1097+
B = A.child( "B" )
10971098

10981099
# Master scene which contains link to above scene
10991100
# C
11001101
# D -> [target.scc, /]
1102+
# E
1103+
# A -> [target.scc, /A]
1104+
# F
1105+
# A
1106+
# B -> [target.scc, /A/B]
11011107

11021108
sceneFile = os.path.join( self.tempDir, "scene.lscc" )
11031109
w = IECoreScene.LinkedScene( sceneFile, IECore.IndexedIO.OpenMode.Write )
11041110
C = w.createChild( "C" )
11051111
D = C.createChild( "D" )
11061112

1113+
E = w.createChild( "E" )
1114+
A1 = E.createChild( "A" )
1115+
1116+
F = w.createChild( "F" )
1117+
A2 = F.createChild( "A" )
1118+
B1 = A2.createChild( "B" )
1119+
1120+
A1.writeLink( A )
11071121
D.writeLink( r )
1122+
B1.writeLink( B )
11081123

1109-
del w, C, D
1124+
del w, C, D, E, F, A1, A2, B1
11101125

11111126
# ok lets read back in our linked scene and try and read the set names
11121127
r = IECoreScene.LinkedScene( sceneFile, IECore.IndexedIO.OpenMode.Read )
11131128
self.assertEqualUnordered( r.setNames(), ['don', 'stew'] )
11141129

1115-
self.assertEqual( r.readSet( "don" ), IECore.PathMatcher(['/C/D/A'] ) )
1116-
self.assertEqual( r.readSet( "stew" ), IECore.PathMatcher(['/C/D/A/B'] ) )
1130+
self.assertEqual( r.readSet( "don" ), IECore.PathMatcher( ['/C/D/A', '/E/A' ] ) )
1131+
self.assertEqual( r.readSet( "stew" ), IECore.PathMatcher( ['/C/D/A/B', '/E/A/B', '/F/A/B' ] ) )
11171132

11181133
self.assertEqualUnordered( r.setNames( includeDescendantSets = False ), [] )
11191134

0 commit comments

Comments
 (0)