Gui: fix crash with the move to the new-style of class SelectionFilterPy

When setting the selection filter below and hovering over an object causes a segmentation fault:
filter = Gui.Selection.Filter('SELECT Part::Feature')
Gui.Selection.addSelectionGate(filter)
This commit is contained in:
wmayer
2023-08-30 09:52:24 +02:00
committed by wwmayer
parent 5e29c03c63
commit a86c0b8928
2 changed files with 5 additions and 1 deletions

View File

@@ -2303,7 +2303,7 @@ PyObject *SelectionSingleton::sAddSelectionGate(PyObject * /*self*/, PyObject *a
if (PyArg_ParseTuple(args, "O!|i",SelectionFilterPy::type_object(),&filterPy,resolve)) {
PY_TRY {
Selection().addSelectionGate(new SelectionFilterGatePython(
static_cast<SelectionFilterPy*>(filterPy)), toEnum(resolve));
SelectionFilterPy::cast(filterPy)), toEnum(resolve));
Py_Return;
}
PY_CATCH;

View File

@@ -45,6 +45,10 @@ public:
public:
static void init_type(); // announce properties and methods
static SelectionFilterPy* cast(PyObject* py) {
using SelectionFilterClass = Py::PythonClassObject<SelectionFilterPy>;
return SelectionFilterClass(py).getCxxObject();
}
SelectionFilterPy(Py::PythonClassInstance* self, Py::Tuple& args, Py::Dict& kdws);