diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2001-02-20 22:27:43 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2001-02-20 22:27:43 (GMT) |
commit | 599ce9c6c2299b085011c426f0893d494cf9403d (patch) | |
tree | 74cf648aeccf4798572a69adcc4aa6b3c34e4a9d /Mac/Modules/dlg/Dlgmodule.c | |
parent | c05abb3bdaa87b6e5ea2d6db1e5d6145ae2b0440 (diff) | |
download | cpython-599ce9c6c2299b085011c426f0893d494cf9403d.zip cpython-599ce9c6c2299b085011c426f0893d494cf9403d.tar.gz cpython-599ce9c6c2299b085011c426f0893d494cf9403d.tar.bz2 |
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.
Diffstat (limited to 'Mac/Modules/dlg/Dlgmodule.c')
-rw-r--r-- | Mac/Modules/dlg/Dlgmodule.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/Mac/Modules/dlg/Dlgmodule.c b/Mac/Modules/dlg/Dlgmodule.c index 070283e..2262b54 100644 --- a/Mac/Modules/dlg/Dlgmodule.c +++ b/Mac/Modules/dlg/Dlgmodule.c @@ -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); |