On OSX passing NULL to NewUniversalFilterProc() does not return NULL but a crashing UPP. This made ModalDialog (and, hence EditPythonPrefs and EasyDialogs and many others) crash. Fixed.
This commit is contained in:
parent
c05abb3bda
commit
599ce9c6c2
|
@ -56,10 +56,12 @@ static pascal Boolean Dlg_UnivFilterProc(DialogPtr dialog,
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ModalFilterProcPtr
|
static ModalFilterUPP
|
||||||
Dlg_PassFilterProc(PyObject *callback)
|
Dlg_PassFilterProc(PyObject *callback)
|
||||||
{
|
{
|
||||||
PyObject *tmp = Dlg_FilterProc_callback;
|
PyObject *tmp = Dlg_FilterProc_callback;
|
||||||
|
static ModalFilterUPP UnivFilterUpp = NULL;
|
||||||
|
|
||||||
Dlg_FilterProc_callback = NULL;
|
Dlg_FilterProc_callback = NULL;
|
||||||
if (callback == Py_None) {
|
if (callback == Py_None) {
|
||||||
Py_XDECREF(tmp);
|
Py_XDECREF(tmp);
|
||||||
|
@ -68,7 +70,9 @@ Dlg_PassFilterProc(PyObject *callback)
|
||||||
Py_INCREF(callback);
|
Py_INCREF(callback);
|
||||||
Dlg_FilterProc_callback = callback;
|
Dlg_FilterProc_callback = callback;
|
||||||
Py_XDECREF(tmp);
|
Py_XDECREF(tmp);
|
||||||
return &Dlg_UnivFilterProc;
|
if ( UnivFilterUpp == NULL )
|
||||||
|
UnivFilterUpp = NewModalFilterUPP(&Dlg_UnivFilterProc);
|
||||||
|
return UnivFilterUpp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Dlg_UserItemProc_callback = NULL;
|
static PyObject *Dlg_UserItemProc_callback = NULL;
|
||||||
|
@ -1077,7 +1081,7 @@ static PyObject *Dlg_ModalDialog(_self, _args)
|
||||||
if (!PyArg_ParseTuple(_args, "O",
|
if (!PyArg_ParseTuple(_args, "O",
|
||||||
&modalFilter))
|
&modalFilter))
|
||||||
return NULL;
|
return NULL;
|
||||||
ModalDialog(NewModalFilterProc(Dlg_PassFilterProc(modalFilter)),
|
ModalDialog(Dlg_PassFilterProc(modalFilter),
|
||||||
&itemHit);
|
&itemHit);
|
||||||
_res = Py_BuildValue("h",
|
_res = Py_BuildValue("h",
|
||||||
itemHit);
|
itemHit);
|
||||||
|
@ -1135,7 +1139,7 @@ static PyObject *Dlg_Alert(_self, _args)
|
||||||
&modalFilter))
|
&modalFilter))
|
||||||
return NULL;
|
return NULL;
|
||||||
_rv = Alert(alertID,
|
_rv = Alert(alertID,
|
||||||
NewModalFilterProc(Dlg_PassFilterProc(modalFilter)));
|
Dlg_PassFilterProc(modalFilter));
|
||||||
_res = Py_BuildValue("h",
|
_res = Py_BuildValue("h",
|
||||||
_rv);
|
_rv);
|
||||||
return _res;
|
return _res;
|
||||||
|
@ -1154,7 +1158,7 @@ static PyObject *Dlg_StopAlert(_self, _args)
|
||||||
&modalFilter))
|
&modalFilter))
|
||||||
return NULL;
|
return NULL;
|
||||||
_rv = StopAlert(alertID,
|
_rv = StopAlert(alertID,
|
||||||
NewModalFilterProc(Dlg_PassFilterProc(modalFilter)));
|
Dlg_PassFilterProc(modalFilter));
|
||||||
_res = Py_BuildValue("h",
|
_res = Py_BuildValue("h",
|
||||||
_rv);
|
_rv);
|
||||||
return _res;
|
return _res;
|
||||||
|
@ -1173,7 +1177,7 @@ static PyObject *Dlg_NoteAlert(_self, _args)
|
||||||
&modalFilter))
|
&modalFilter))
|
||||||
return NULL;
|
return NULL;
|
||||||
_rv = NoteAlert(alertID,
|
_rv = NoteAlert(alertID,
|
||||||
NewModalFilterProc(Dlg_PassFilterProc(modalFilter)));
|
Dlg_PassFilterProc(modalFilter));
|
||||||
_res = Py_BuildValue("h",
|
_res = Py_BuildValue("h",
|
||||||
_rv);
|
_rv);
|
||||||
return _res;
|
return _res;
|
||||||
|
@ -1192,7 +1196,7 @@ static PyObject *Dlg_CautionAlert(_self, _args)
|
||||||
&modalFilter))
|
&modalFilter))
|
||||||
return NULL;
|
return NULL;
|
||||||
_rv = CautionAlert(alertID,
|
_rv = CautionAlert(alertID,
|
||||||
NewModalFilterProc(Dlg_PassFilterProc(modalFilter)));
|
Dlg_PassFilterProc(modalFilter));
|
||||||
_res = Py_BuildValue("h",
|
_res = Py_BuildValue("h",
|
||||||
_rv);
|
_rv);
|
||||||
return _res;
|
return _res;
|
||||||
|
@ -1400,7 +1404,7 @@ static PyObject *Dlg_SetUserItemHandler(_self, _args)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new == Py_None) {
|
if (new == NULL || new == Py_None) {
|
||||||
new = NULL;
|
new = NULL;
|
||||||
_res = Py_None;
|
_res = Py_None;
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
|
|
|
@ -15,7 +15,7 @@ DialogRef = DialogPtr
|
||||||
OptHandle = OpaqueByValueType("Handle", "OptResObj")
|
OptHandle = OpaqueByValueType("Handle", "OptResObj")
|
||||||
|
|
||||||
ModalFilterProcPtr = InputOnlyType("PyObject*", "O")
|
ModalFilterProcPtr = InputOnlyType("PyObject*", "O")
|
||||||
ModalFilterProcPtr.passInput = lambda name: "NewModalFilterProc(Dlg_PassFilterProc(%s))" % name
|
ModalFilterProcPtr.passInput = lambda name: "Dlg_PassFilterProc(%s)" % name
|
||||||
ModalFilterUPP = ModalFilterProcPtr
|
ModalFilterUPP = ModalFilterProcPtr
|
||||||
|
|
||||||
RgnHandle = OpaqueByValueType("RgnHandle", "ResObj")
|
RgnHandle = OpaqueByValueType("RgnHandle", "ResObj")
|
||||||
|
@ -79,10 +79,12 @@ static pascal Boolean Dlg_UnivFilterProc(DialogPtr dialog,
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ModalFilterProcPtr
|
static ModalFilterUPP
|
||||||
Dlg_PassFilterProc(PyObject *callback)
|
Dlg_PassFilterProc(PyObject *callback)
|
||||||
{
|
{
|
||||||
PyObject *tmp = Dlg_FilterProc_callback;
|
PyObject *tmp = Dlg_FilterProc_callback;
|
||||||
|
static ModalFilterUPP UnivFilterUpp = NULL;
|
||||||
|
|
||||||
Dlg_FilterProc_callback = NULL;
|
Dlg_FilterProc_callback = NULL;
|
||||||
if (callback == Py_None) {
|
if (callback == Py_None) {
|
||||||
Py_XDECREF(tmp);
|
Py_XDECREF(tmp);
|
||||||
|
@ -91,7 +93,9 @@ Dlg_PassFilterProc(PyObject *callback)
|
||||||
Py_INCREF(callback);
|
Py_INCREF(callback);
|
||||||
Dlg_FilterProc_callback = callback;
|
Dlg_FilterProc_callback = callback;
|
||||||
Py_XDECREF(tmp);
|
Py_XDECREF(tmp);
|
||||||
return &Dlg_UnivFilterProc;
|
if ( UnivFilterUpp == NULL )
|
||||||
|
UnivFilterUpp = NewModalFilterUPP(&Dlg_UnivFilterProc);
|
||||||
|
return UnivFilterUpp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *Dlg_UserItemProc_callback = NULL;
|
static PyObject *Dlg_UserItemProc_callback = NULL;
|
||||||
|
@ -267,7 +271,7 @@ setuseritembody = """
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new == Py_None) {
|
if (new == NULL || new == Py_None) {
|
||||||
new = NULL;
|
new = NULL;
|
||||||
_res = Py_None;
|
_res = Py_None;
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
|
|
Loading…
Reference in New Issue