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:
Jack Jansen 2001-02-20 22:27:43 +00:00
parent c05abb3bda
commit 599ce9c6c2
2 changed files with 20 additions and 12 deletions

View File

@ -56,10 +56,12 @@ static pascal Boolean Dlg_UnivFilterProc(DialogPtr dialog,
return rv;
}
static ModalFilterProcPtr
static ModalFilterUPP
Dlg_PassFilterProc(PyObject *callback)
{
PyObject *tmp = Dlg_FilterProc_callback;
static ModalFilterUPP UnivFilterUpp = NULL;
Dlg_FilterProc_callback = NULL;
if (callback == Py_None) {
Py_XDECREF(tmp);
@ -68,7 +70,9 @@ Dlg_PassFilterProc(PyObject *callback)
Py_INCREF(callback);
Dlg_FilterProc_callback = callback;
Py_XDECREF(tmp);
return &Dlg_UnivFilterProc;
if ( UnivFilterUpp == NULL )
UnivFilterUpp = NewModalFilterUPP(&Dlg_UnivFilterProc);
return UnivFilterUpp;
}
static PyObject *Dlg_UserItemProc_callback = NULL;
@ -1077,7 +1081,7 @@ static PyObject *Dlg_ModalDialog(_self, _args)
if (!PyArg_ParseTuple(_args, "O",
&modalFilter))
return NULL;
ModalDialog(NewModalFilterProc(Dlg_PassFilterProc(modalFilter)),
ModalDialog(Dlg_PassFilterProc(modalFilter),
&itemHit);
_res = Py_BuildValue("h",
itemHit);
@ -1135,7 +1139,7 @@ static PyObject *Dlg_Alert(_self, _args)
&modalFilter))
return NULL;
_rv = Alert(alertID,
NewModalFilterProc(Dlg_PassFilterProc(modalFilter)));
Dlg_PassFilterProc(modalFilter));
_res = Py_BuildValue("h",
_rv);
return _res;
@ -1154,7 +1158,7 @@ static PyObject *Dlg_StopAlert(_self, _args)
&modalFilter))
return NULL;
_rv = StopAlert(alertID,
NewModalFilterProc(Dlg_PassFilterProc(modalFilter)));
Dlg_PassFilterProc(modalFilter));
_res = Py_BuildValue("h",
_rv);
return _res;
@ -1173,7 +1177,7 @@ static PyObject *Dlg_NoteAlert(_self, _args)
&modalFilter))
return NULL;
_rv = NoteAlert(alertID,
NewModalFilterProc(Dlg_PassFilterProc(modalFilter)));
Dlg_PassFilterProc(modalFilter));
_res = Py_BuildValue("h",
_rv);
return _res;
@ -1192,7 +1196,7 @@ static PyObject *Dlg_CautionAlert(_self, _args)
&modalFilter))
return NULL;
_rv = CautionAlert(alertID,
NewModalFilterProc(Dlg_PassFilterProc(modalFilter)));
Dlg_PassFilterProc(modalFilter));
_res = Py_BuildValue("h",
_rv);
return _res;
@ -1400,7 +1404,7 @@ static PyObject *Dlg_SetUserItemHandler(_self, _args)
return NULL;
}
if (new == Py_None) {
if (new == NULL || new == Py_None) {
new = NULL;
_res = Py_None;
Py_INCREF(Py_None);

View File

@ -15,7 +15,7 @@ DialogRef = DialogPtr
OptHandle = OpaqueByValueType("Handle", "OptResObj")
ModalFilterProcPtr = InputOnlyType("PyObject*", "O")
ModalFilterProcPtr.passInput = lambda name: "NewModalFilterProc(Dlg_PassFilterProc(%s))" % name
ModalFilterProcPtr.passInput = lambda name: "Dlg_PassFilterProc(%s)" % name
ModalFilterUPP = ModalFilterProcPtr
RgnHandle = OpaqueByValueType("RgnHandle", "ResObj")
@ -79,10 +79,12 @@ static pascal Boolean Dlg_UnivFilterProc(DialogPtr dialog,
return rv;
}
static ModalFilterProcPtr
static ModalFilterUPP
Dlg_PassFilterProc(PyObject *callback)
{
PyObject *tmp = Dlg_FilterProc_callback;
static ModalFilterUPP UnivFilterUpp = NULL;
Dlg_FilterProc_callback = NULL;
if (callback == Py_None) {
Py_XDECREF(tmp);
@ -91,7 +93,9 @@ Dlg_PassFilterProc(PyObject *callback)
Py_INCREF(callback);
Dlg_FilterProc_callback = callback;
Py_XDECREF(tmp);
return &Dlg_UnivFilterProc;
if ( UnivFilterUpp == NULL )
UnivFilterUpp = NewModalFilterUPP(&Dlg_UnivFilterProc);
return UnivFilterUpp;
}
static PyObject *Dlg_UserItemProc_callback = NULL;
@ -267,7 +271,7 @@ setuseritembody = """
return NULL;
}
if (new == Py_None) {
if (new == NULL || new == Py_None) {
new = NULL;
_res = Py_None;
Py_INCREF(Py_None);