summaryrefslogtreecommitdiffstats
path: root/Mac
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2000-12-14 22:29:00 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2000-12-14 22:29:00 (GMT)
commit80716f0e618cc5689161cea55328e4c8bb1f4b3d (patch)
tree88615014fc363053b739261f4877b54c551b82d3 /Mac
parent4550b00c80b064a3594d6d648fd7e164ffa59286 (diff)
downloadcpython-80716f0e618cc5689161cea55328e4c8bb1f4b3d.zip
cpython-80716f0e618cc5689161cea55328e4c8bb1f4b3d.tar.gz
cpython-80716f0e618cc5689161cea55328e4c8bb1f4b3d.tar.bz2
Set autodispose only if RefCon isn't set yet on the window. This way we don't accidentally dispose of windows that are actually dialogs-in-disguise.
Diffstat (limited to 'Mac')
-rw-r--r--Mac/Modules/win/Winmodule.c114
-rw-r--r--Mac/Modules/win/winsupport.py9
2 files changed, 117 insertions, 6 deletions
diff --git a/Mac/Modules/win/Winmodule.c b/Mac/Modules/win/Winmodule.c
index 02f0efe..800bad0 100644
--- a/Mac/Modules/win/Winmodule.c
+++ b/Mac/Modules/win/Winmodule.c
@@ -45,8 +45,12 @@ PyObject *WinObj_New(itself)
it = PyObject_NEW(WindowObject, &Window_Type);
if (it == NULL) return NULL;
it->ob_itself = itself;
- SetWRefCon(itself, (long)it);
- it->ob_freeit = PyMac_AutoDisposeWindow;
+ it->ob_freeit = NULL;
+ if (GetWRefCon(itself) == 0)
+ {
+ SetWRefCon(itself, (long)it);
+ it->ob_freeit = PyMac_AutoDisposeWindow;
+ }
return (PyObject *)it;
}
WinObj_Convert(v, p_itself)
@@ -73,12 +77,13 @@ WinObj_Convert(v, p_itself)
static void WinObj_dealloc(self)
WindowObject *self;
{
- if (self->ob_itself) SetWRefCon(self->ob_itself, 0);
if (self->ob_freeit && self->ob_itself)
{
+ SetWRefCon(self->ob_itself, 0);
self->ob_freeit(self->ob_itself);
}
self->ob_itself = NULL;
+ self->ob_freeit = NULL;
PyMem_DEL(self);
}
@@ -394,6 +399,38 @@ static PyObject *WinObj_DrawNew(_self, _args)
}
#endif
+static PyObject *WinObj_PaintOne(_self, _args)
+ WindowObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+ RgnHandle clobberedRgn;
+ if (!PyArg_ParseTuple(_args, "O&",
+ ResObj_Convert, &clobberedRgn))
+ return NULL;
+ PaintOne(_self->ob_itself,
+ clobberedRgn);
+ Py_INCREF(Py_None);
+ _res = Py_None;
+ return _res;
+}
+
+static PyObject *WinObj_PaintBehind(_self, _args)
+ WindowObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+ RgnHandle clobberedRgn;
+ if (!PyArg_ParseTuple(_args, "O&",
+ ResObj_Convert, &clobberedRgn))
+ return NULL;
+ PaintBehind(_self->ob_itself,
+ clobberedRgn);
+ Py_INCREF(Py_None);
+ _res = Py_None;
+ return _res;
+}
+
static PyObject *WinObj_CalcVis(_self, _args)
WindowObject *_self;
PyObject *_args;
@@ -407,6 +444,22 @@ static PyObject *WinObj_CalcVis(_self, _args)
return _res;
}
+static PyObject *WinObj_CalcVisBehind(_self, _args)
+ WindowObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+ RgnHandle clobberedRgn;
+ if (!PyArg_ParseTuple(_args, "O&",
+ ResObj_Convert, &clobberedRgn))
+ return NULL;
+ CalcVisBehind(_self->ob_itself,
+ clobberedRgn);
+ Py_INCREF(Py_None);
+ _res = Py_None;
+ return _res;
+}
+
static PyObject *WinObj_BringToFront(_self, _args)
WindowObject *_self;
PyObject *_args;
@@ -1032,6 +1085,26 @@ static PyObject *WinObj_IsWindowPathSelectClick(_self, _args)
return _res;
}
+static PyObject *WinObj_WindowPathSelect(_self, _args)
+ WindowObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+ OSStatus _err;
+ MenuHandle menu;
+ SInt32 outMenuResult;
+ if (!PyArg_ParseTuple(_args, "O&",
+ MenuObj_Convert, &menu))
+ return NULL;
+ _err = WindowPathSelect(_self->ob_itself,
+ menu,
+ &outMenuResult);
+ if (_err != noErr) return PyMac_Error(_err);
+ _res = Py_BuildValue("l",
+ outMenuResult);
+ return _res;
+}
+
static PyObject *WinObj_HiliteWindowFrameForDrag(_self, _args)
WindowObject *_self;
PyObject *_args;
@@ -1242,6 +1315,29 @@ static PyObject *WinObj_GetWindowBounds(_self, _args)
return _res;
}
+static PyObject *WinObj_ResizeWindow(_self, _args)
+ WindowObject *_self;
+ PyObject *_args;
+{
+ PyObject *_res = NULL;
+ Boolean _rv;
+ Point startPoint;
+ Rect sizeConstraints;
+ Rect newContentRect;
+ if (!PyArg_ParseTuple(_args, "O&O&",
+ PyMac_GetPoint, &startPoint,
+ PyMac_GetRect, &sizeConstraints))
+ return NULL;
+ _rv = ResizeWindow(_self->ob_itself,
+ startPoint,
+ &sizeConstraints,
+ &newContentRect);
+ _res = Py_BuildValue("bO&",
+ _rv,
+ PyMac_BuildRect, &newContentRect);
+ return _res;
+}
+
static PyObject *WinObj_SetWindowBounds(_self, _args)
WindowObject *_self;
PyObject *_args;
@@ -1860,8 +1956,14 @@ static PyMethodDef WinObj_methods[] = {
{"DrawNew", (PyCFunction)WinObj_DrawNew, 1,
"(Boolean update) -> None"},
#endif
+ {"PaintOne", (PyCFunction)WinObj_PaintOne, 1,
+ "(RgnHandle clobberedRgn) -> None"},
+ {"PaintBehind", (PyCFunction)WinObj_PaintBehind, 1,
+ "(RgnHandle clobberedRgn) -> None"},
{"CalcVis", (PyCFunction)WinObj_CalcVis, 1,
"() -> None"},
+ {"CalcVisBehind", (PyCFunction)WinObj_CalcVisBehind, 1,
+ "(RgnHandle clobberedRgn) -> None"},
{"BringToFront", (PyCFunction)WinObj_BringToFront, 1,
"() -> None"},
{"SendBehind", (PyCFunction)WinObj_SendBehind, 1,
@@ -1942,6 +2044,8 @@ static PyMethodDef WinObj_methods[] = {
"(Boolean modified) -> None"},
{"IsWindowPathSelectClick", (PyCFunction)WinObj_IsWindowPathSelectClick, 1,
"(EventRecord event) -> (Boolean _rv)"},
+ {"WindowPathSelect", (PyCFunction)WinObj_WindowPathSelect, 1,
+ "(MenuHandle menu) -> (SInt32 outMenuResult)"},
{"HiliteWindowFrameForDrag", (PyCFunction)WinObj_HiliteWindowFrameForDrag, 1,
"(Boolean hilited) -> None"},
{"TransitionWindow", (PyCFunction)WinObj_TransitionWindow, 1,
@@ -1964,6 +2068,8 @@ static PyMethodDef WinObj_methods[] = {
"(Boolean collapse) -> None"},
{"GetWindowBounds", (PyCFunction)WinObj_GetWindowBounds, 1,
"(WindowRegionCode regionCode) -> (Rect globalBounds)"},
+ {"ResizeWindow", (PyCFunction)WinObj_ResizeWindow, 1,
+ "(Point startPoint, Rect sizeConstraints) -> (Boolean _rv, Rect newContentRect)"},
{"SetWindowBounds", (PyCFunction)WinObj_SetWindowBounds, 1,
"(WindowRegionCode regionCode, Rect globalBounds) -> None"},
{"RepositionWindow", (PyCFunction)WinObj_RepositionWindow, 1,
@@ -2767,7 +2873,7 @@ WinObj_WhichWindow(w)
Py_INCREF(it);
} else {
it = (PyObject *) GetWRefCon(w);
- if (it == NULL || ((WindowObject *)it)->ob_itself != w) {
+ if (it == NULL || ((WindowObject *)it)->ob_itself != w || !WinObj_Check(it)) {
it = WinObj_New(w);
((WindowObject *)it)->ob_freeit = NULL;
} else {
diff --git a/Mac/Modules/win/winsupport.py b/Mac/Modules/win/winsupport.py
index 2b96555..cbc5246 100644
--- a/Mac/Modules/win/winsupport.py
+++ b/Mac/Modules/win/winsupport.py
@@ -84,7 +84,7 @@ WinObj_WhichWindow(w)
Py_INCREF(it);
} else {
it = (PyObject *) GetWRefCon(w);
- if (it == NULL || ((WindowObject *)it)->ob_itself != w) {
+ if (it == NULL || ((WindowObject *)it)->ob_itself != w || !WinObj_Check(it)) {
it = WinObj_New(w);
((WindowObject *)it)->ob_freeit = NULL;
} else {
@@ -103,8 +103,12 @@ class MyObjectDefinition(GlobalObjectDefinition):
Output("void (*ob_freeit)(%s ptr);", self.itselftype)
def outputInitStructMembers(self):
GlobalObjectDefinition.outputInitStructMembers(self)
+ Output("it->ob_freeit = NULL;")
+ Output("if (GetWRefCon(itself) == 0)")
+ OutLbrace()
Output("SetWRefCon(itself, (long)it);")
Output("it->ob_freeit = PyMac_AutoDisposeWindow;")
+ OutRbrace()
def outputCheckConvertArg(self):
OutLbrace("if (DlgObj_Check(v))")
Output("*p_itself = DlgObj_ConvertToWindow(v);")
@@ -115,12 +119,13 @@ class MyObjectDefinition(GlobalObjectDefinition):
if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
""")
def outputCleanupStructMembers(self):
- Output("if (self->ob_itself) SetWRefCon(self->ob_itself, 0);")
Output("if (self->ob_freeit && self->ob_itself)")
OutLbrace()
+ Output("SetWRefCon(self->ob_itself, 0);")
Output("self->ob_freeit(self->ob_itself);")
OutRbrace()
Output("self->ob_itself = NULL;")
+ Output("self->ob_freeit = NULL;")
## def outputFreeIt(self, itselfname):
## Output("DisposeWindow(%s);", itselfname)
# From here on it's basically all boiler plate...