From e788741631df55d702f61bfa2ce51289b3be3627 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 31 Jan 2015 17:26:03 +0100 Subject: [PATCH] + fixes #0001938: addObject() maximum recursion depth exceeded Error --- src/App/DocumentObjectGroupPyImp.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/App/DocumentObjectGroupPyImp.cpp b/src/App/DocumentObjectGroupPyImp.cpp index d12d91b7d..fb552f43d 100644 --- a/src/App/DocumentObjectGroupPyImp.cpp +++ b/src/App/DocumentObjectGroupPyImp.cpp @@ -91,10 +91,13 @@ PyObject* DocumentObjectGroupPy::addObject(PyObject *args) Py::Object vp = static_cast(proxy)->getValue(); if (vp.hasAttr(std::string("addObject"))) { Py::Callable method(vp.getAttr(std::string("addObject"))); - Py::Tuple args(1); - args[0] = Py::Object(object); - method.apply(args); - Py_Return; + // check which this method belongs to to avoid an infinite recursion + if (method.getAttr(std::string("__self__")) != Py::Object(this)) { + Py::Tuple args(1); + args[0] = Py::Object(object); + method.apply(args); + Py_Return; + } } } } @@ -128,10 +131,13 @@ PyObject* DocumentObjectGroupPy::removeObject(PyObject *args) Py::Object vp = static_cast(proxy)->getValue(); if (vp.hasAttr(std::string("removeObject"))) { Py::Callable method(vp.getAttr(std::string("removeObject"))); - Py::Tuple args(1); - args[0] = Py::Object(object); - method.apply(args); - Py_Return; + // check which this method belongs to to avoid an infinite recursion + if (method.getAttr(std::string("__self__")) != Py::Object(this)) { + Py::Tuple args(1); + args[0] = Py::Object(object); + method.apply(args); + Py_Return; + } } } }