[Pythonmac-SIG] Ctl.CreateRootControl( window ) always returns None

Jack Jansen Jack.Jansen@cwi.nl
Fri, 12 Mar 1999 10:11:13 +0100


Recently, "Steven D. Majewski" <sdm7g@virginia.edu> said:
> 
> Thanks.
> Looks like the same bug infects GetSuperControl, so the wrapper funcion
> CtlObj_WhichControl is suspect.  Is it supposed to be calling 
> GetControlReference() ? Shouldn't it be the control itself and not
> the RefCon value ? 

The problem is deeper, it is a deisng problem. Let me explain, and if
someone knows an answer please help me in the right direction.

When FindControl() or various other Ctl routines return a control they 
return an existing control, and I would like to return the correct
Python object to the Python program. So, for all controls created
through NewControl or GetNewControl we set the refcon field to the
Python object, and we can go back and forth between Python object and
control.

Controls that have been created by other means (in dialog boxes, for
instance) are a problem, though. They don't have a corresponding
Python object and no refcon field, so it is a bit unclear what I
should do with them. Currently I just refuse to return them, which is
clearly not the optimal solution. I could create the control object
and put in the refcon link, or I could create it without the refcon
link. The first solution has the advantage that if the control is
returned twice you get the same Python object twice, but the
disadvantage that memory will be leaked (as the control is freed by
some other package you won't get the chance to free the Python
object).

The second method doesn't leak memory, but if you call FindControl
twice it will return two different Python objects pointing to the same 
Control object.

Comments and insights, anyone?
--
Jack Jansen             | ++++ stop the execution of Mumia Abu-Jamal ++++
Jack.Jansen@cwi.nl      | ++++ if you agree copy these lines to your sig ++++
http://www.cwi.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm