[Gambas-user] What are circular references, and how to avoid?

Benoit Minisini gambas at ...1...
Tue Jan 22 18:02:45 CET 2008


On mardi 22 janvier 2008, ron wrote:
> On Tuesday 22 January 2008 12:42, Jaap Cramer wrote:
> > Hi
> >
> > I discovered some. But when I search for ToolPanelContainer, FExpander,
> > ToolPanel, Expander, I cant find them. I never use those words, so how
> > can I have made a circular reference? And FExpander isn't even the name
> > of a control I made...
> >
> > BTW, how bad is a circular reference?
> >
> > tnx in advance :-)
> > Jaap
> >
> >> What is it
> >> how serious is this :-)
> >> and how do I avoid it?
> >>
> >> Jaap
>
> The explanation of Benoit is correct but I do also not understand it 100%
> for following reason.
>
> I had same finding in the past, and if you search in the complete source
> code you can find those "ToolPanelContainer, FExpander, ToolPanel,
> Expander" in components written in gambas. And that is exactly what I do
> not understand.
>
> > Easy, you avoid it by not creating circular references. :-)
> >
> > A circular reference is when an object A has a variable that points at an
> > object B, and that at the same time the object B has a variable that
> > points at the object A.
>
> For me it was stopping to use some of those components.
>
> Ron
>

If you prevent a form from being freed because of a circular reference, then 
all form contents are not freed too. For example, if you have a Toolbar 
inside this form, then you will see internal classes used for implementing 
this Toolbar in the warning messages. Nothing terrible in that...

If I see the project, I will tell where the circular references come from.

Regards,

-- 
Benoit Minisini




More information about the User mailing list