From: Jack Jansen Date: Fri, 2 Feb 2001 22:41:48 +0000 (+0000) Subject: Accept Dialogs and Windows where Grafports are expected (such as in SetPort) and... X-Git-Tag: v2.1b1~529 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dc2ac8d39f852bd0925c3462d37046015c79f150;p=thirdparty%2FPython%2Fcpython.git Accept Dialogs and Windows where Grafports are expected (such as in SetPort) and do a MacOSX compatible cast. Bit of a hack, but good enough for now. --- diff --git a/Mac/Modules/qd/Qdmodule.c b/Mac/Modules/qd/Qdmodule.c index 34476d4d69c6..aece598109b0 100644 --- a/Mac/Modules/qd/Qdmodule.c +++ b/Mac/Modules/qd/Qdmodule.c @@ -144,8 +144,14 @@ GrafObj_Convert(v, p_itself) PyObject *v; GrafPtr *p_itself; { - if (DlgObj_Check(v) || WinObj_Check(v)) { - *p_itself = ((GrafPortObject *)v)->ob_itself; + if (DlgObj_Check(v)) { + DialogRef dlg = (DialogRef)((GrafPortObject *)v)->ob_itself; + *p_itself = (GrafPtr)GetWindowPort(GetDialogWindow(dlg)); + return 1; + } + if (WinObj_Check(v)) { + WindowRef win = (WindowRef)((GrafPortObject *)v)->ob_itself; + *p_itself = (GrafPtr)GetWindowPort(win); return 1; } if (!GrafObj_Check(v)) diff --git a/Mac/Modules/qd/qdsupport.py b/Mac/Modules/qd/qdsupport.py index f57cf17ecd20..fe606f5a94fa 100644 --- a/Mac/Modules/qd/qdsupport.py +++ b/Mac/Modules/qd/qdsupport.py @@ -219,8 +219,14 @@ class MyGRObjectDefinition(GlobalObjectDefinition): def outputCheckNewArg(self): Output("if (itself == NULL) return PyMac_Error(resNotFound);") def outputCheckConvertArg(self): - OutLbrace("if (DlgObj_Check(v) || WinObj_Check(v))") - Output("*p_itself = ((GrafPortObject *)v)->ob_itself;") + OutLbrace("if (DlgObj_Check(v))") + Output("DialogRef dlg = (DialogRef)((GrafPortObject *)v)->ob_itself;") + Output("*p_itself = (GrafPtr)GetWindowPort(GetDialogWindow(dlg));") + Output("return 1;") + OutRbrace() + OutLbrace("if (WinObj_Check(v))") + Output("WindowRef win = (WindowRef)((GrafPortObject *)v)->ob_itself;") + Output("*p_itself = (GrafPtr)GetWindowPort(win);") Output("return 1;") OutRbrace() def outputGetattrHook(self):