Commit f6e299b5 authored by Dan Mašek's avatar Dan Mašek

Fix #11206

parent 6ffc4876
......@@ -1569,7 +1569,13 @@ static PyObject *pycvSetMouseCallback(PyObject*, PyObject *args, PyObject *kw)
if (param == NULL) {
param = Py_None;
}
ERRWRAP2(setMouseCallback(name, OnMouse, Py_BuildValue("OO", on_mouse, param)));
static PyObject* last_param = NULL;
if (last_param) {
Py_DECREF(last_param);
last_param = NULL;
}
last_param = Py_BuildValue("OO", on_mouse, param);
ERRWRAP2(setMouseCallback(name, OnMouse, last_param));
Py_RETURN_NONE;
}
#endif
......@@ -1603,7 +1609,13 @@ static PyObject *pycvCreateTrackbar(PyObject*, PyObject *args)
PyErr_SetString(PyExc_TypeError, "on_change must be callable");
return NULL;
}
ERRWRAP2(createTrackbar(trackbar_name, window_name, value, count, OnChange, Py_BuildValue("OO", on_change, Py_None)));
static PyObject* last_param = NULL;
if (last_param) {
Py_DECREF(last_param);
last_param = NULL;
}
last_param = Py_BuildValue("OO", on_change, Py_None);
ERRWRAP2(createTrackbar(trackbar_name, window_name, value, count, OnChange, last_param));
Py_RETURN_NONE;
}
......@@ -1649,7 +1661,13 @@ static PyObject *pycvCreateButton(PyObject*, PyObject *args, PyObject *kw)
userdata = Py_None;
}
ERRWRAP2(createButton(button_name, OnButtonChange, Py_BuildValue("OO", on_change, userdata), button_type, initial_button_state != 0));
static PyObject* last_param = NULL;
if (last_param) {
Py_DECREF(last_param);
last_param = NULL;
}
last_param = Py_BuildValue("OO", on_change, userdata);
ERRWRAP2(createButton(button_name, OnButtonChange, last_param, button_type, initial_button_state != 0));
Py_RETURN_NONE;
}
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment