Gui: Prevent crash when trying to create ExpressionBinding without arguments

This commit is contained in:
marioalexis
2022-08-22 15:37:55 -03:00
committed by wwmayer
parent 0e24ed6342
commit f4b01a5568

View File

@@ -53,13 +53,15 @@ void ExpressionBindingPy::init_type()
PyObject *ExpressionBindingPy::PyMake(struct _typeobject *, PyObject * args, PyObject *)
{
Py::Tuple tuple(args);
PyObject* pyObj;
if (!PyArg_ParseTuple(args,"O", &pyObj))
return nullptr;
ExpressionBinding* expr = nullptr;
PythonWrapper wrap;
wrap.loadWidgetsModule();
QWidget* obj = dynamic_cast<QWidget*>(wrap.toQObject(tuple.getItem(0)));
QWidget* obj = dynamic_cast<QWidget*>(wrap.toQObject(Py::Object(pyObj)));
if (obj) {
do {
QuantitySpinBox* sb = qobject_cast<QuantitySpinBox*>(obj);