Skip to content

Commit

Permalink
Trade: ensure the deprecated SceneData constructor uses default delet…
Browse files Browse the repository at this point in the history
…ers.

Otherwise the instances wouldn't be usable from AbstractImporter
subclasses.
  • Loading branch information
mosra committed Sep 22, 2021
1 parent 2c988a8 commit b77ea63
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Magnum/Trade/SceneData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,11 @@ SceneData::SceneData(std::vector<UnsignedInt> children2D, std::vector<UnsignedIn
{NoInit, children.size(), objects},
{NoInit, children.size(), parents},
};
_fields = {InPlaceInit, {
SceneFieldData{SceneField::Parent, objects, parents}
}};
/* Can't use InPlaceInit as that creates an Array with a non-default
deleter, which then trips up on an assertion when such an instance gets
returned from AbstractImporter */
_fields = Containers::Array<SceneFieldData>{1};
_fields[0] = SceneFieldData{SceneField::Parent, objects, parents};
Utility::copy(children, objects);
constexpr Int parent[]{-1};
Utility::copy(Containers::stridedArrayView(parent).broadcasted<0>(parents.size()), parents);
Expand Down
5 changes: 5 additions & 0 deletions src/Magnum/Trade/Test/SceneDataTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,11 @@ void SceneDataTest::constructDeprecated() {
CORRADE_COMPARE_AS(scene.field<Int>(0),
Containers::arrayView<Int>({-1, -1, -1, -1}),
TestSuite::Compare::Container);

/* The deleters have to be trivial, otherwise this instance wouldn't be
usable from an AbstractImporter */
CORRADE_VERIFY(!scene.releaseFieldData().deleter());
CORRADE_VERIFY(!scene.releaseData().deleter());
}
#endif

Expand Down

0 comments on commit b77ea63

Please sign in to comment.