[fxruby-users] create issue

Jeroen van der Zijp jeroen at fox-toolkit.org
Thu Feb 2 20:56:58 EST 2006

On Thursday 02 February 2006 05:45, Meinrad Recheis wrote:
> dear lyle,
> i want to propose a solution to an unecessary complication in fxruby:
> calling create on widgets whose parents are not created yet!
> in previous versions it caused a segfault in the latest versions it
> results in application halt and this message: "trying to create window
> before creating parent window."
> i think it complicates code too much. now i often code something like that:
>  wdg.create if App.instance.created?
> therefore i had to wrap Fox::FXApp into a singleton class App which
> remembers if it has been created yet. that's a convenient workaround
> for me but it is unnecessary.
> but how about fxruby putting out a warning  "warning: trying to create
> window before creating parent window." (a linenumber would be
> confortable) and simply ignore that call if the application is not yet
> created?
> it would allow to reuse code without needing to worry about the
> create-order-issue.
> kind regards,

Just to explain a bit more about the create() issue:- in C++, objects are
not "complete" until the constructor has finished running.  Thus, an object
can not be fully realized inside its constructor since what we think of
as a complete constructor may actually be only a part of the object, since
the developer could have subclassed the class.

Take e.g. FXButton.  There's no way for me to tell if you have subclassed
it or not, and thus I can not consider the FXButton to be fully constructed
at the end of FXButton's constructor.  Indeed, all the vtable entries at
that time still refer to FXButton's vtable entries, and not the developer's
subclass thereof.

This explains the dichotomy between construction and creation.  We can do 
the latter only if the former is known to be completed.

There are also other reasons why it is needed; for example, we can construct
a widget tree [e.g. programmatically or by serialization] and not realize it 
until its complete.

Hope this helps,

		- Jeroen

| Copyright (C) 19:40 02/ 2/2006 Jeroen van der Zijp.   All Rights Reserved. |

More information about the fxruby-users mailing list