From 3ca859acf7aec7f6bd97533c8b785bf496344d09 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 19 Jun 2020 15:07:57 +0200 Subject: [PATCH] Gui: [skip ci] fix Gui.subgraphFromObject and improve error text if wrapping fails --- src/Base/swigpyrun.cpp | 1 + src/Base/swigpyrun.inl | 7 +++++-- src/Gui/Application.cpp | 12 ++++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Base/swigpyrun.cpp b/src/Base/swigpyrun.cpp index 5ef080bd0e..63245ac7df 100644 --- a/src/Base/swigpyrun.cpp +++ b/src/Base/swigpyrun.cpp @@ -24,6 +24,7 @@ #include "PreCompiled.h" #include "PyExport.h" #include "Exception.h" +#include #if (defined(HAVE_SWIG) && (HAVE_SWIG == 1)) #if defined(__clang__) # pragma clang diagnostic push diff --git a/src/Base/swigpyrun.inl b/src/Base/swigpyrun.inl index 3f0e10479c..8956b30ad8 100644 --- a/src/Base/swigpyrun.inl +++ b/src/Base/swigpyrun.inl @@ -29,8 +29,11 @@ int createSWIGPointerObj_T(const char* TypeName, void* obj, PyObject** ptr, int swig_type_info * swig_type = 0; swig_type = SWIG_TypeQuery(TypeName); - if (!swig_type) - throw Base::RuntimeError("Cannot find type information for requested type"); + if (!swig_type) { + std::stringstream str; + str << "SWIG: Cannot find type information for requested type: " << TypeName; + throw Base::RuntimeError(str.str()); + } *ptr = SWIG_NewPointerObj(obj,swig_type,own); if (*ptr == 0) diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index f51306374c..66524c71af 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -201,8 +201,16 @@ FreeCADGui_subgraphFromObject(PyObject * /*self*/, PyObject *args) vp->setDisplayMode(modes.front().c_str()); node = vp->getRoot()->copy(); node->ref(); - std::string type = "So"; - type += node->getTypeId().getName().getString(); + std::string prefix = "So"; + std::string type = node->getTypeId().getName().getString(); + // doesn't start with the prefix 'So' + if (type.rfind("So", 0) != 0) { + type = prefix + type; + } + else if (type == "SoFCSelectionRoot") { + type = "SoSeparator"; + } + type += " *"; PyObject* proxy = 0; proxy = Base::Interpreter().createSWIGPointerObj("pivy.coin", type.c_str(), (void*)node, 1);