# Tree repainting problem when openness changes

**URL:** <https://forum.juce.com/t/tree-repainting-problem-when-openness-changes/4448>\
**Category:** MacOSX and iOS\
**Created:** [October 29, 2009, 10:33am UTC](https://forum.juce.com/t/tree-repainting-problem-when-openness-changes/4448 "2009-10-29T10:33:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![francis](https://avatars.discourse-cdn.com/v4/letter/f/ac8455/32.png) [@francis](https://forum.juce.com/u/francis)\
**Post date:** [October 29, 2009, 10:33am UTC](https://forum.juce.com/t/tree-repainting-problem-when-openness-changes/4448/1 "2009-10-29T10:33:57Z")

</div>

Hi,

On my mac (MacOS X 10.4, Xcode 2.41, Juce 1.50), sub-items are not drawn when I open a tree item. In order to be drawn, I need to perform another operation on the tree (either passing the mouse over the new sub-items, or changing the selected item, or resizing the tree, …).

I performed some tests and it seems that TreeView::itemsChanged() needs to be called a second time after opening an item, in order to have the sub-items drawn. The problems seems to be related to the async-update.

I do not exactly understand why updates need to be async, and I naively tried the following modification:

```auto
void TreeView::itemsChanged() throw()
{
    needsRecalculating = true;
    repaint();
#ifdef JUCE_MAC
    handleAsyncUpdate();
#else
    triggerAsyncUpdate();
#endif // JUCE_MAC
}
```

That solves my problem ! However, my fix is very ugly …

Has anyone the same kind of problems ? How could this be solved in a clean way ?

Francis.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [October 29, 2009, 12:06pm UTC](https://forum.juce.com/t/tree-repainting-problem-when-openness-changes/4448/2 "2009-10-29T12:06:51Z")

</div>

I don’t understand why it’d make any difference whether the update is performed immediately or later (?)… Surely either way, your new nodes are in place and the routine will run.

And why would it be different on the mac?? This is a very odd one!

---

<div class="post-metadata">

**Author:** ![stick](https://avatars.discourse-cdn.com/v4/letter/s/d07c76/32.png) [@stick](https://forum.juce.com/u/stick)\
**Post date:** [October 29, 2009, 12:49pm UTC](https://forum.juce.com/t/tree-repainting-problem-when-openness-changes/4448/3 "2009-10-29T12:49:13Z")

</div>

Hi ! Have a look there too 😉 :  
[http://www.rawmaterialsoftware.com/juceforum/viewtopic.php?t=2890&highlight=treeview+bug](http://www.rawmaterialsoftware.com/juceforum/viewtopic.php?t=2890&highlight=treeview+bug)

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [October 29, 2009, 4:09pm UTC](https://forum.juce.com/t/tree-repainting-problem-when-openness-changes/4448/4 "2009-10-29T16:09:58Z")

</div>

Ok, I’ve figured it out, I think. It’s pretty obscure.

The tree relies on the fact that if you call repaint() during a paint() callback, it’ll cause another repaint to be triggered. But a few quick tests show that on the mac, any calls to repaint() during a paint() method were getting thrown away.

I’ve checked in a fix that gives the mac windowing code the correct behaviour, and hopefully that should sort out the treeview!

---

<div class="post-metadata">

**Author:** ![otristan](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@otristan](https://forum.juce.com/u/otristan)\
**Post date:** [October 29, 2009, 4:18pm UTC](https://forum.juce.com/t/tree-repainting-problem-when-openness-changes/4448/5 "2009-10-29T16:18:31Z")

</div>

Not totally related but is there two kind of commit in git ?  
at  
[http://sourceforge.net/projects/juce/develop](http://sourceforge.net/projects/juce/develop)  
it says last commit on 2009-09-19  
which obviously is not the right time

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [October 29, 2009, 5:06pm UTC](https://forum.juce.com/t/tree-repainting-problem-when-openness-changes/4448/6 "2009-10-29T17:06:08Z")

</div>

Weird… if I do a ‘git log’ all the details are correct, but sourceforge seems to be screwing up its list… Any git experts know what might be wrong?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [October 29, 2009, 5:10pm UTC](https://forum.juce.com/t/tree-repainting-problem-when-openness-changes/4448/7 "2009-10-29T17:10:47Z")

</div>

It’s correct if you look at this list:  
[http://juce.git.sourceforge.net/git/gitweb.cgi?p=juce/juce;a=log](http://juce.git.sourceforge.net/git/gitweb.cgi?p=juce/juce;a=log)

I guess sourceforge is just being a bit flakey.
