Skip to content

Commit

Permalink
Gui: [skip ci] fix Gui.subgraphFromObject and improve error text if w…
Browse files Browse the repository at this point in the history
…rapping fails
  • Loading branch information
wwmayer committed Jun 19, 2020
1 parent 0cb4d4e commit 70b2d49
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/Base/swigpyrun.cpp
Expand Up @@ -24,6 +24,7 @@
#include "PreCompiled.h"
#include "PyExport.h"
#include "Exception.h"
#include <sstream>
#if (defined(HAVE_SWIG) && (HAVE_SWIG == 1))
#if defined(__clang__)
# pragma clang diagnostic push
Expand Down
7 changes: 5 additions & 2 deletions src/Base/swigpyrun.inl
Expand Up @@ -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)
Expand Down
12 changes: 10 additions & 2 deletions src/Gui/Application.cpp
Expand Up @@ -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);
Expand Down

0 comments on commit 70b2d49

Please sign in to comment.