From 803281f2bc6ebcdc9f569c28bea55c2d10ae4e1c Mon Sep 17 00:00:00 2001 From: Joseph Mirabel <jmirabel@laas.fr> Date: Fri, 16 Feb 2018 13:41:20 +0100 Subject: [PATCH] Hack to fix SEGV when calling IDL createWindow from embeded python interpreter. --- src/gepetto/corbaserver/client.py | 9 +++++++++ src/gui/pythonwidget.cc | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/src/gepetto/corbaserver/client.py b/src/gepetto/corbaserver/client.py index 7c50390..1e1c496 100644 --- a/src/gepetto/corbaserver/client.py +++ b/src/gepetto/corbaserver/client.py @@ -74,6 +74,15 @@ class Client: for client in clients: self.makeClient (client) + # In the python interpreter of gepetto-gui, gui.createWindow + # crashes for an obscure reason. This hack makes it work. + try: + self.gui.createWindow = lambda x: mainWindow.createView(x).wid() + # At this point, we are in the python interpreter of gepetto-gui + except: + # At this point, we are NOT in the python interpreter of gepetto-gui + pass + def _getIIOPurl (): """ Returns "corbaloc:iiop:<host>:<port>/NameService" diff --git a/src/gui/pythonwidget.cc b/src/gui/pythonwidget.cc index cd95e9a..3c94982 100644 --- a/src/gui/pythonwidget.cc +++ b/src/gui/pythonwidget.cc @@ -70,6 +70,10 @@ namespace gepetto { toggleViewAction()->setShortcut(gepetto::gui::DockKeyShortcutBase + Qt::Key_A); connect(button_, SIGNAL(clicked()), SLOT(browseFile())); + + // Hack to make "createWindow" function work properly + PythonQtObjectPtr client = PythonQt::self()->importModule ("gepetto.corbaserver.client"); + client.addObject ("mainWindow", MainWindow::instance()); } PythonWidget::~PythonWidget() -- GitLab