From c574b43d35e08f85843bb72938850ecd1dde7d82 Mon Sep 17 00:00:00 2001 From: Jack Jansen Date: Fri, 12 Apr 1996 16:26:59 +0000 Subject: Fixed a nasty bug where FindControl could return a reference to a destroyed python object. --- Mac/Modules/ctl/Ctlmodule.c | 2 +- Mac/Modules/ctl/ctlgen.py | 2 +- Mac/Modules/ctl/ctlscan.py | 3 ++- Mac/Modules/ctl/ctlsupport.py | 4 +++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Mac/Modules/ctl/Ctlmodule.c b/Mac/Modules/ctl/Ctlmodule.c index bc690cd..33111f5 100644 --- a/Mac/Modules/ctl/Ctlmodule.c +++ b/Mac/Modules/ctl/Ctlmodule.c @@ -95,7 +95,7 @@ CtlObj_Convert(v, p_itself) static void CtlObj_dealloc(self) ControlObject *self; { - /* Cleanup of self->ob_itself goes here */ + SetCRefCon(self->ob_itself, (long)0); /* Make it forget about us */ PyMem_DEL(self); } diff --git a/Mac/Modules/ctl/ctlgen.py b/Mac/Modules/ctl/ctlgen.py index 451253a..eefd175 100644 --- a/Mac/Modules/ctl/ctlgen.py +++ b/Mac/Modules/ctl/ctlgen.py @@ -1,4 +1,4 @@ -# Generated from 'flap:CW8 Gold:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:Controls.h' +# Generated from 'Sap:CW8 Gold:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:Controls.h' f = Function(ControlRef, 'NewControl', (WindowRef, 'theWindow', InMode), diff --git a/Mac/Modules/ctl/ctlscan.py b/Mac/Modules/ctl/ctlscan.py index e36db2c..661cbfe 100644 --- a/Mac/Modules/ctl/ctlscan.py +++ b/Mac/Modules/ctl/ctlscan.py @@ -3,11 +3,12 @@ import addpack addpack.addpack(':Tools:bgen:bgen') from scantools import Scanner +from bgenlocations import TOOLBOXDIR def main(): input = "Controls.h" output = "ctlgen.py" - defsoutput = "Controls.py" + defsoutput = TOOLBOXDIR + "Controls.py" scanner = MyScanner(input, output, defsoutput) scanner.scan() scanner.close() diff --git a/Mac/Modules/ctl/ctlsupport.py b/Mac/Modules/ctl/ctlsupport.py index c87922a..cef9f8a 100644 --- a/Mac/Modules/ctl/ctlsupport.py +++ b/Mac/Modules/ctl/ctlsupport.py @@ -68,7 +68,9 @@ class MyObjectDefinition(GlobalObjectDefinition): def outputInitStructMembers(self): GlobalObjectDefinition.outputInitStructMembers(self) Output("SetCRefCon(itself, (long)it);") - + def outputCleanupStructMembers(self): + Output("SetCRefCon(self->ob_itself, (long)0); /* Make it forget about us */") + # Create the generator groups and link them module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff) object = MyObjectDefinition(OBJECTNAME, OBJECTPREFIX, OBJECTTYPE) -- cgit v0.12