summaryrefslogtreecommitdiffstats
path: root/Mac/Modules/win/winsupport.py
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/Modules/win/winsupport.py
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/Modules/win/winsupport.py')
-rw-r--r--Mac/Modules/win/winsupport.py9
1 files changed, 7 insertions, 2 deletions
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...