# Re: fxRuby: changing icon in TreeItem crashes

**URL:** <https://www.ruby-forum.com/t/re-fxruby-changing-icon-in-treeitem-crashes/57117>\
**Category:** Ruby\
**Created:** [April 7, 2006, 10:16am UTC](https://www.ruby-forum.com/t/re-fxruby-changing-icon-in-treeitem-crashes/57117 "2006-04-07T10:16:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kloubakov\_Yura](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/dfb087/32.png) [@Kloubakov\_Yura](https://www.ruby-forum.com/u/Kloubakov_Yura)\
**Post date:** [April 7, 2006, 10:16am UTC](https://www.ruby-forum.com/t/re-fxruby-changing-icon-in-treeitem-crashes/57117/1 "2006-04-07T10:16:12Z")

</div>

Christer,

You have to explicitly call “create” for the new icon to  
create the server side object. Fox does it automatically  
for all the objects it can see at the time “create” is  
called for the FXApp object if I remember correctly.

> ```
> begin
> 
> ```
> 
> …
> 
> doc = makeIcon(“minidoc.png”)

```
doc.create

```

> @tree.currentItem.text = “new icon coming …”  
> @tree.currentItem.closedIcon = doc # crash!
> 
> I had no problem adding icons when the TreeItem was constructed.
> 
> I’m using fox14.
> 
> Christer

Yura.

---

<div class="post-metadata">

**Author:** ![Kloubakov\_Yura](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/dfb087/32.png) [@Kloubakov\_Yura](https://www.ruby-forum.com/u/Kloubakov_Yura)\
**Post date:** [April 7, 2006, 4:02pm UTC](https://www.ruby-forum.com/t/re-fxruby-changing-icon-in-treeitem-crashes/57117/2 "2006-04-07T16:02:44Z")

</div>

Thanks Yura, this solved my problem!

Do I have to destroy or delete also, to balance create?

Christer

Kloubakov Yura wrote:

> Christer,
> 
> You have to explicitly call “create” for the new icon to  
> create the server side object. Fox does it automatically  
> for all the objects it can see at the time “create” is  
> called for the FXApp object if I remember correctly.
> 
> > ```
> > begin
> > 
> > ```
> > 
> > …
> > 
> > doc = makeIcon(“minidoc.png”)
> 
> ```
> doc.create
> 
> ```
> 
> > @tree.currentItem.text = “new icon coming …”  
> > @tree.currentItem.closedIcon = doc # crash!
> > 
> > I had no problem adding icons when the TreeItem was constructed.
> > 
> > I’m using fox14.
> > 
> > Christer
> 
> Yura.

---

<div class="post-metadata">

**Author:** ![Kloubakov\_Yura](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/dfb087/32.png) [@Kloubakov\_Yura](https://www.ruby-forum.com/u/Kloubakov_Yura)\
**Post date:** [April 7, 2006, 4:09pm UTC](https://www.ruby-forum.com/t/re-fxruby-changing-icon-in-treeitem-crashes/57117/3 "2006-04-07T16:09:02Z")

</div>

On 4/7/06, Christer N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Do I have to destroy or delete also, to balance create?

No, the icon’s resources will be destroyed automatically when it’s  
garbage-collected.
