issue #0002867: AttachExtension crash

This commit is contained in:
wmayer 2017-01-20 13:17:11 +01:00
parent 14ae74f468
commit ac7750fab6
3 changed files with 47 additions and 0 deletions

View File

@ -26,6 +26,37 @@
#include <Base/BaseClass.h>
#include <App/PropertyContainerPy.h>
#define PYTHON_TYPE_DEF(_class_, _subclass_) \
class _class_ : public _subclass_ \
{ \
public: \
static PyTypeObject Type; \
public: \
_class_(Base::BaseClass *pcObject, PyTypeObject *T = &Type); \
virtual ~_class_(); \
};
#define PYTHON_TYPE_IMP(_class_, _subclass_) \
PyTypeObject _class_::Type = { \
PyObject_HEAD_INIT(&PyType_Type) \
0, \
""#_class_"", \
sizeof(_class_), \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_CLASS, \
""#_class_"", \
0, 0, 0, 0, 0, 0, 0, 0, 0, \
&_subclass_::Type, \
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 \
}; \
_class_::_class_(Base::BaseClass *pcObject, PyTypeObject *T) \
: _subclass_(reinterpret_cast<_subclass_::PointerType>(pcObject), T) \
{ \
} \
_class_::~_class_() \
{ \
}
namespace App
{

View File

@ -63,6 +63,8 @@
#include "PrimitiveFeature.h"
#include <Mod/Part/App/PartFeaturePy.h>
#include <App/FeaturePythonPyImp.h>
#include <Base/Console.h>
#include <Base/Exception.h>
#include <Base/Reader.h>
@ -105,6 +107,19 @@ App::DocumentObjectExecReturn* Primitive::execute(void) {
return Part::Feature::execute();
}
namespace Part {
PYTHON_TYPE_DEF(PrimitivePy, PartFeaturePy)
PYTHON_TYPE_IMP(PrimitivePy, PartFeaturePy)
}
PyObject* Primitive::getPyObject()
{
if (PythonObject.is(Py::_None())){
// ref counter is set to 1
PythonObject = Py::Object(new PrimitivePy(this),true);
}
return Py::new_reference_to(PythonObject);
}
void Primitive::Restore(Base::XMLReader &reader)
{

View File

@ -44,6 +44,7 @@ public:
/// recalculate the feature
App::DocumentObjectExecReturn *execute(void);
short mustExecute() const;
PyObject* getPyObject();
//@}
protected: