> > Because the underlying toolkit uses its own "picture" object that is not
> > automatically reassigned to the control automatically. In other words,
> > assume that the Picture property returns a copy of the underlying
> > picture.
> 
> I hope this doesn't create extra unneeded picture objects in memory,
> so I can perform code like:
> 
>    DIM Pic AS Picture
>    Pic = MenuCustomColor.Picture
>    Pic.Fill(Dialog.Color)
>    MenuCustomColor.Picture = Pic
> 
> for any number of times without memory penalties.
> 
> Please confirm this.
> 
> Thank you,
> David
> 

Nothing is leaked in the process. At least as far as I am concerned! 

My explanations were simplified, so here is more details...

When you do:

        MenuCustomColor.Picture = Pic

Here is what happens internally (for gb.qt):

1) The old internal MenuCustomColor.Picture is dereferenced.

2) The Pic Gambas object is assigned to the internal MenuCustomColor.Picture 
and referenced.

3) The internal Qt QPixmap associated with MenuCustomColor.Picture is assigned 
to the internal Qt QMenu associated with MenuCustomColor with the setIcon() 
method. So the QPixmap has to be transformed into a QIcon before.

When you do:

        MenuCustomColor.Picture.Fill(MyColor)

It happens:

1) The internal MenuCustomColor.Picture is returned.

2) The picture is filled with MyColor, i.e. the internal Qt QPixmap associated 
with the picture object is filled.

And that's all. As there is no link between that QPixmap and the icon 
associated with the Menu, you see no change on the screen. You must write 
MenuCustomColor.Picture = MenuCustomColor.Picture to repeat the step #3 above.

You have the same problem with Button, PictureBox, TreeView, ListView...

Note: It is actually a bit more complex than that, as a QPixmap is internally 
associated with the true X11 Pixmap resource that is stored on the server. But 
it is automatically managed by the toolkit, so it is out of my control.

Regards,

-- 
Benoît Minisini

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to