Hi, I have the following C++ function that is going to be binded to Python:
Effect Effect::getInput(int inputNumber) const { boost::shared_ptr<Natron::Node> node = _node->getInput(inputNumber); return Effect(node); } The return value has a bool isNull() const method to determine if the object is valid or not. In the type system I do the following: <object-type name="Effect"> <modify-function signature="getInput(int)const"> <modify-argument index="return"> <replace-type modified-type="PyObject" /> </modify-argument> <inject-code class="target" position="beginning"> %RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME(%ARGUMENT_NAMES); if (%0.isNull()) { Py_INCREF(Py_None); %PYARG_0 = Py_None; } else { %PYARG_0 = %CONVERTTOPYTHON[%RETURN_TYPE](%0); } </inject-code> </modify-function> </object-type> Which is expanded in c++ to : // Begin code injection Effect cppResult = cppSelf->getInput(cppArg0); if (cppResult.isNull()) { Py_INCREF(Py_None); pyResult = Py_None; } else { ///Crash in the following line pyResult = Shiboken::Conversions::copyToPython((SbkObjectType*)SbkNatronEngineTypes[SBK_EFFECT_IDX], &cppResult); } // End of code injection Unfortunately the code crashes in the indicated line above when invoking the code from the Python interpreter. Any idea on what I’m doing wrong ?
_______________________________________________ PySide mailing list PySide@qt-project.org http://lists.qt-project.org/mailman/listinfo/pyside