sudara / melatonin_inspector

A JUCE module that gives you the ability to inspect and visually edit (non-destructively) components in your UI.
MIT License
145 stars 17 forks source link

Feature/setroot #96

Closed FigBug closed 9 months ago

FigBug commented 9 months ago

Add Inspector::setRoot so the component that is being inspected can change. Optionally, the component being inspected can be whatever top level juce component is under the mouse.

sudara commented 9 months ago

Trying this out locally, I triggered an assert on inspector_component:194

jassert (selectComponentCallback);

and then pushing through that, things crashed in MessageManager::runDispatchLoop()

sudara commented 9 months ago

It seems like setRoot (which calls ensureTreeIsConstructed) is being called before the callbacks are setup.

It happens when i click my button to construct:

            inspector = std::make_unique<melatonin::Inspector> (*this);
            inspector->onClose = [this]() { inspector.reset(); };
FigBug commented 9 months ago

Looks like bool inspectorEnabled is never initialized. So this error occurs if it is randomly initialized to 'true'. Setting it to false resolves the issue.