From 29fc5fada6e03196b4eb312280ced5112d4074bb Mon Sep 17 00:00:00 2001 From: Dan McGarry Date: Thu, 5 Dec 2024 14:47:37 -0800 Subject: [PATCH] Fix UsdMayaPrimWriter and UsdMayaPrimReader Python Wrappings The PrimReaderWrapper and PrimWriterWrapper helper classes ignored the template parameter when deriving from TfPyPolymorphic. This caused unexpected duplicate entries in boost::python's type conversion table. boost::python silently accepted this, but the new pxr_boost::python in OpenUSD 24.11 flagged this with an assert in debug mode. The wrappings for ShaderReaderWrapper and ShaderWriterWrapper incorrectly specified PrimReaderWrapper<> and PrimWriterWrapper<> as their bases. For example, this meant that passing an instance of a ShaderReader to a a Python-wrapped C++ function that takes a UsdMayaPrimReader would fail. This doesn't show up in practice since clients aren't expected to create their own instances of these types but it seemed good to fix anyway. --- lib/mayaUsd/python/wrapPrimReader.cpp | 4 ++-- lib/mayaUsd/python/wrapPrimWriter.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/mayaUsd/python/wrapPrimReader.cpp b/lib/mayaUsd/python/wrapPrimReader.cpp index 1b1f567740..2f8e5bf6e9 100644 --- a/lib/mayaUsd/python/wrapPrimReader.cpp +++ b/lib/mayaUsd/python/wrapPrimReader.cpp @@ -38,7 +38,7 @@ PXR_NAMESPACE_USING_DIRECTIVE template class PrimReaderWrapper : public T - , public TfPyPolymorphic + , public TfPyPolymorphic { public: typedef PrimReaderWrapper This; @@ -580,7 +580,7 @@ void wrapShaderReader() typedef UsdMayaShaderReader This; - class_>, PXR_BOOST_PYTHON_NAMESPACE::noncopyable> + class_, PXR_BOOST_PYTHON_NAMESPACE::noncopyable> c("ShaderReader", no_init); scope s(c); diff --git a/lib/mayaUsd/python/wrapPrimWriter.cpp b/lib/mayaUsd/python/wrapPrimWriter.cpp index 625933cea1..56f4f6a644 100644 --- a/lib/mayaUsd/python/wrapPrimWriter.cpp +++ b/lib/mayaUsd/python/wrapPrimWriter.cpp @@ -38,7 +38,7 @@ PXR_NAMESPACE_USING_DIRECTIVE template class PrimWriterWrapper : public T - , public TfPyPolymorphic + , public TfPyPolymorphic { public: typedef PrimWriterWrapper This; @@ -99,7 +99,7 @@ class PrimWriterWrapper const SdfPathVector& default_GetModelPaths() const { return base_t::GetModelPaths(); } const SdfPathVector& GetModelPaths() const override { - if (Override o = GetOverride("GetModelPaths")) { + if (TfPyOverride o = this->GetOverride("GetModelPaths")) { auto res = std::function( TfPyCall(o))(); if (res) { @@ -131,7 +131,7 @@ class PrimWriterWrapper } const UsdMayaUtil::MDagPathMap& GetDagToUsdPathMapping() const override { - if (Override o = GetOverride("GetDagToUsdPathMapping")) { + if (TfPyOverride o = this->GetOverride("GetDagToUsdPathMapping")) { auto res = std::function( TfPyCall(o))(); if (res) { @@ -735,7 +735,7 @@ void wrapShaderWriter() { PXR_BOOST_PYTHON_NAMESPACE::class_< ShaderWriterWrapper, - PXR_BOOST_PYTHON_NAMESPACE::bases>, + PXR_BOOST_PYTHON_NAMESPACE::bases, PXR_BOOST_PYTHON_NAMESPACE::noncopyable> c("ShaderWriter", PXR_BOOST_PYTHON_NAMESPACE::no_init);