Skip to content

Commit

Permalink
add define to inactivate some code blocks if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Jun 3, 2019
1 parent bd8fc55 commit 3789a26
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Base/PyObjectBase.cpp
Expand Up @@ -32,6 +32,8 @@
#include "Console.h"
#include "Interpreter.h"

#define ATTR_TRACKING

using namespace Base;

PyObject* Base::BaseExceptionFreeCADError = 0;
Expand Down Expand Up @@ -164,6 +166,7 @@ PyObject* PyObjectBase::__getattro(PyObject * obj, PyObject *attro)
return NULL;
}

#ifdef ATTR_TRACKING
// If an attribute references this as parent then reset it (bug #0002902)
PyObject* cur = pyObj->getTrackedAttribute(attr);
if (cur) {
Expand All @@ -173,9 +176,10 @@ PyObject* PyObjectBase::__getattro(PyObject * obj, PyObject *attro)
pyObj->untrackAttribute(attr);
}
}
#endif

PyObject* value = pyObj->_getattr(attr);
#if 1
#ifdef ATTR_TRACKING
if (value && PyObject_TypeCheck(value, &(PyObjectBase::Type))) {
if (!static_cast<PyObjectBase*>(value)->isConst() &&
!static_cast<PyObjectBase*>(value)->isNotTracking()) {
Expand Down Expand Up @@ -223,6 +227,7 @@ int PyObjectBase::__setattro(PyObject *obj, PyObject *attro, PyObject *value)
return -1;
}

#ifdef ATTR_TRACKING
// If an attribute references this as parent then reset it
// before setting the new attribute
PyObject* cur = static_cast<PyObjectBase*>(obj)->getTrackedAttribute(attr);
Expand All @@ -233,9 +238,10 @@ int PyObjectBase::__setattro(PyObject *obj, PyObject *attro, PyObject *value)
static_cast<PyObjectBase*>(obj)->untrackAttribute(attr);
}
}
#endif

int ret = static_cast<PyObjectBase*>(obj)->_setattr(attr, value);
#if 1
#ifdef ATTR_TRACKING
if (ret == 0) {
static_cast<PyObjectBase*>(obj)->startNotify();
}
Expand Down

0 comments on commit 3789a26

Please sign in to comment.