From 3f99b6ec26e476234c75391e593375838b8b4f51 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Mon, 24 Feb 2014 16:10:51 -0300 Subject: [PATCH] Part: Fixed python representation of Part2DObject - fixes #1387 --- src/Mod/Part/App/Part2DObject.cpp | 13 +++++++++++-- src/Mod/Part/App/Part2DObjectPyImp.cpp | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Mod/Part/App/Part2DObject.cpp b/src/Mod/Part/App/Part2DObject.cpp index 4afbc3bad..c4e55e696 100644 --- a/src/Mod/Part/App/Part2DObject.cpp +++ b/src/Mod/Part/App/Part2DObject.cpp @@ -20,7 +20,7 @@ * * ***************************************************************************/ - + #include "PreCompiled.h" #ifndef _PreComp_ # include @@ -48,6 +48,8 @@ #include "Part2DObject.h" #include "Geometry.h" +#include +#include "Part2DObjectPy.h" using namespace Part; @@ -311,7 +313,14 @@ namespace App { PROPERTY_SOURCE_TEMPLATE(Part::Part2DObjectPython, Part::Part2DObject) template<> const char* Part::Part2DObjectPython::getViewProviderName(void) const { return "PartGui::ViewProvider2DObjectPython"; -} + } + template<> PyObject* Part::Part2DObjectPython::getPyObject(void) { + if (PythonObject.is(Py::_None())) { + // ref counter is set to 1 + PythonObject = Py::Object(new FeaturePythonPyT(this),true); + } + return Py::new_reference_to(PythonObject); + } /// @endcond // explicit template instantiation diff --git a/src/Mod/Part/App/Part2DObjectPyImp.cpp b/src/Mod/Part/App/Part2DObjectPyImp.cpp index 9be787f0c..ba7ceba8f 100644 --- a/src/Mod/Part/App/Part2DObjectPyImp.cpp +++ b/src/Mod/Part/App/Part2DObjectPyImp.cpp @@ -12,7 +12,7 @@ using namespace Part; // returns a string which represents the object e.g. when printed in python std::string Part2DObjectPy::representation(void) const { - return std::string(""); + return std::string(""); }