# TreeView crash on OS X

**URL:** <https://forum.juce.com/t/treeview-crash-on-os-x/3788>\
**Category:** MacOSX and iOS\
**Created:** [March 26, 2009, 3:39pm UTC](https://forum.juce.com/t/treeview-crash-on-os-x/3788 "2009-03-26T15:39:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![zamrate](https://avatars.discourse-cdn.com/v4/letter/z/f4b2a3/32.png) [@zamrate](https://forum.juce.com/u/zamrate)\
**Post date:** [March 26, 2009, 3:39pm UTC](https://forum.juce.com/t/treeview-crash-on-os-x/3788/1 "2009-03-26T15:39:57Z")

</div>

I’m wondering what made it crash, happened 2 times now. What could it be? This is JUCE V1.46.  
Basically, I’m doing this in a Thread (not the main GUI Thread):

using MessageManagerLock then adding subItem via TreeViewItem::addSubItem()

I guess it crashes because somewhere there’s repaint() called in it? Should I use callFunctionOnMessageThread() ?

Thread 6 Crashed:  
0 com.apple.CoreGraphics 0x96a41d9f shape\_union + 687  
1 com.apple.CoreGraphics 0x96a4a074 CGSUnionRegion + 264  
2 com.apple.HIServices 0x93b85a75 CreateUnion(\_\_HIShape  
const\*, \_\_HIShape const\*, void\*\*) + 57  
3 com.apple.HIServices 0x93b89106 HIShapeCreateUnion + 36  
4 com.apple.HIToolbox 0x9389b590  
HIView::Invalidate(\_\_HIShape const\*) + 346  
5 com.apple.HIToolbox 0x939030e5  
HIViewSetNeedsDisplayInRect + 113  
6 com.schaack.touch 0x001d6b88  
juce::HIViewComponentPeer::repaint(int, int, int, int) + 236  
7 com.schaack.touch 0x0009706b  
juce::Component::repaint() + 93  
8 com.schaack.touch 0x0009920e  
juce::Component::setBounds(int, int, int, int) + 438  
9 com.schaack.touch 0x000996c3  
juce::Component::setBounds(juce::Rectangle const&) + 47  
10 com.schaack.touch 0x001e371c  
juce::TreeViewContentComponent::updateComponents() + 880  
11 com.schaack.touch 0x000924c0  
juce::TreeView::handleAsyncUpdate() + 98  
12 com.schaack.touch 0x000927e9  
juce::TreeViewItem::addSubItem(juce::TreeViewItem\*, int) + 569  
13 com.schaack.touch 0x000439f8  
QuadFileTreeComponent::run() + 426  
14 com.schaack.touch 0x000faa42  
juce::Thread::threadEntryPoint(juce::Thread\*) + 274  
15 com.schaack.touch 0x00074679  
juce::threadEntryProc(void\*) + 17  
16 libSystem.B.dylib 0x94bf8095 \_pthread\_start + 321  
17 libSystem.B.dylib 0x94bf7f52 thread\_start + 34

---

<div class="post-metadata">

**Author:** ![zamrate](https://avatars.discourse-cdn.com/v4/letter/z/f4b2a3/32.png) [@zamrate](https://forum.juce.com/u/zamrate)\
**Post date:** [March 26, 2009, 6:12pm UTC](https://forum.juce.com/t/treeview-crash-on-os-x/3788/2 "2009-03-26T18:12:16Z")

</div>

It would be nice to have a Thread-safe addSubItem()…

---

<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:** [March 28, 2009, 11:29am UTC](https://forum.juce.com/t/treeview-crash-on-os-x/3788/3 "2009-03-28T11:29:46Z")

</div>

No idea, but as this is all defunct carbon code, I can’t really offer to spend any time investigating…

---

<div class="post-metadata">

**Author:** ![zamrate](https://avatars.discourse-cdn.com/v4/letter/z/f4b2a3/32.png) [@zamrate](https://forum.juce.com/u/zamrate)\
**Post date:** [March 28, 2009, 3:50pm UTC](https://forum.juce.com/t/treeview-crash-on-os-x/3788/4 "2009-03-28T15:50:52Z")

</div>

What has Thread-safety of TreeViewItem::addSubItem() to do with Carbon?  
The code is just not Thread-safe because repaint() is called in there (and maybe other functions that are not Thread-safe).

---

<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:** [March 30, 2009, 10:30am UTC](https://forum.juce.com/t/treeview-crash-on-os-x/3788/5 "2009-03-30T10:30:32Z")

</div>

Sorry, I thought you were asking why it had crashed there.

Well, you could always just wrap a messagemanagerlock around your call to addSubItem. I can’t easily add that to the treeview because to avoid deadlocks, you’d need to pass your thread to the messagemanagerlock constructor.

---

<div class="post-metadata">

**Author:** ![zamrate](https://avatars.discourse-cdn.com/v4/letter/z/f4b2a3/32.png) [@zamrate](https://forum.juce.com/u/zamrate)\
**Post date:** [March 31, 2009, 4:14am UTC](https://forum.juce.com/t/treeview-crash-on-os-x/3788/6 "2009-03-31T04:14:41Z")

</div>

I _did_ put a MessageManagerLock around it. It still crashed! (That was written, too in my original message!). So, now, I want to know: what can this be?

---

<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:** [March 31, 2009, 2:30pm UTC](https://forum.juce.com/t/treeview-crash-on-os-x/3788/7 "2009-03-31T14:30:50Z")

</div>

MessageManagerLocks have changed a lot since the old days of 1.46, and I suspect that it might not have been correctly locking it for you.

---

<div class="post-metadata">

**Author:** ![asair](https://avatars.discourse-cdn.com/v4/letter/a/e79b87/32.png) [@asair](https://forum.juce.com/u/asair)\
**Post date:** [June 22, 2009, 7:17pm UTC](https://forum.juce.com/t/treeview-crash-on-os-x/3788/8 "2009-06-22T19:17:55Z")

</div>

Sorry to up that, I encounter the same things.

> > Zamrate: did you solve that with a MessageListener ?
