TreeView crashes

Hi Guys,

I have a crash in Treeview if I click an item while the widget content is being changed

Here is the stack

|#0|0x000000010070498c in juce::Rectangle<int>::getWidth() const|
|---|---|
|#1|0x0000000100833b4e in juce::Viewport::getViewWidth() const|
|#2|0x000000010084ec75 in juce::TreeViewItem::getItemPosition(bool)|
|#3|0x00000001008db28b in juce::TreeView::ItemComponent::resized()|
|#4|0x00000001007b7759 in juce::Component::sendMovedResizedMessages(bool, bool)|
|#5|0x00000001007b76a4 in juce::Component::sendMovedResizedMessagesIfPending()|
|#6|0x00000001007b755b in juce::Component::setBounds(int, int, int, int)|
|#7|0x00000001007b79b3 in juce::Component::setSize(int, int)|
|#8|0x00000001008d7c32 in juce::TreeView::ContentComponent::updateComponents()|
|#9|0x000000010084f0ab in juce::TreeView::TreeViewport::updateComponents(bool)|
|#10|0x0000000100981ae8 in juce::TreeView::TreeViewport::visibleAreaChanged(juce::Rectangle<int> const&) |
|#11|0x00000001007f8c7d in juce::Viewport::updateVisibleArea()|
|#12|0x00000001007f95d5 in juce::Viewport::componentMovedOrResized(juce::Component&, bool, bool)|
|#13|0x0000000100914349 in juce::Component::sendMovedResizedMessages(bool, bool)::$_3::operator()(juce::ComponentListener&) const|
|#14|0x00000001007b7957 in void juce::ListenerList<juce::ComponentListener, juce::Array<juce::ComponentListener*, juce::DummyCriticalSection, 0> >::callChecked<juce::Component::sendMovedResizedMessages(bool, bool)::$_3, juce::Component::BailOutChecker>(juce::Component::BailOutChecker const&, juce::Component::sendMovedResizedMessages(bool, bool)::$_3&&)|
|#15|0x00000001007b78ad in juce::Component::sendMovedResizedMessages(bool, bool)|
|#16|0x00000001007b76a4 in juce::Component::sendMovedResizedMessagesIfPending()|
|#17|0x00000001007b755b in juce::Component::setBounds(int, int, int, int)|
|#18|0x00000001007b79b3 in juce::Component::setSize(int, int)|
|#19|0x000000010084c7cd in juce::TreeView::updateVisibleItems()|
|#20|0x00000001007e8e2c in juce::TreeViewItem::treeHasChanged()|
|#21|0x00000001008504ab in juce::TreeViewItem::clearSubItems()|
|#22|0x00000001019197d8 in uvi::VolumeGroupItem::handleAsyncUpdate()|
|#23|0x00000001006e470b in juce::AsyncUpdater::AsyncUpdaterMessage::messageCallback()|
|#24|0x00000001006e9e33 in juce::MessageQueue::deliverNextMessage()|
|#25|0x00000001006e9d86 in juce::MessageQueue::runLoopCallback()|
|#26|0x00000001006e9a78 in juce::MessageQueue::runLoopSourceCallback(void*)|

in juce::TreeView::ContentComponent::updateComponents()
I am in the case
if (isMouseDraggingInChildComp (*comp))

What is supposed to do this comp->setSize (0, 0); ?

Thanks !

Is this using the latest tip of develop? If so, can you post a minimal example which reproduces the crash? It would help in tracking this down.

Happen in develop,
add to the ValueTreeDemo file

class ValueTreeItemComponent : public Component
{
public:
  ValueTreeItemComponent(TreeViewItem *pItem)
  : label("coucou")
  {
    addAndMakeVisible(&label);
  }
  
  ~ValueTreeItemComponent()
  {
  }
  
  void resized() override
  {
    label.setBounds(0, 0, getWidth(), getHeight());
  }
  
  juce::Label label;
};

and to ValueTreeItem

std::unique_ptr<juce::Component> createItemComponent() override
    {
        return std::make_unique<ValueTreeItemComponent>(this);
    }

and replace ValueTreeDemo::timerCallback impl by

void timerCallback() override
{
    undoManager.beginNewTransaction();
  
  rootItem->clearSubItems();
  rootItem->refreshSubItems();
}

click some item and at some point…boom :slight_smile:

Here is the full file
ValueTreesDemo.h (10.3 KB)

Thanks !

Thanks for the example! This should be fixed on develop now.

all good now.

Thanks !