child->setBound() in resize() error

Hello, I am trying to create a resizable audio plugin.
I thought that a valid approach is to get the initial width&heigh of the Editor and the position of every child component at the end of the Editor constructor and then find the proportional position of each child according to the current editor width&heigh in the resize()

End of Editor Constructor:

ChildrenComponents = getChildren();     //Array<Component*>

setResizable(true, true);
setResizeLimits(700, 340, 2000, 1500);
setSize(900, 400);

As a dummy start of resizing every child I do the following in the resize()

for (int i = 0; i < getNumChildComponents(); i++) {
     Component* child = ChildrenComponents[i];
    
     Rectangle<int> newPos = {10,10,10,10};
     child->setBounds(newPos);
}

When I play around resizing my stand-alone application window fast though, I get the following exception:

#if JUCE_DEBUG
    // It's a very bad idea to try to resize a window during its paint() method!
    jassert (! (flags.isInsidePaintCall && wasResized && isOnDesktop()));
#endif

and if I continue the execution it gets a read access violation a few lines later in:

else if (cachedImage != nullptr) {
   cachedImage->invalidateAll();
} 

The only things I have related to image are some ImageButtons.
My paint() method is completely empty.

What is the stack trace when you get the assertion?

Stack Trace before the exception:

|>| MyComponent.exe!juce::Component::setBounds(int x, int y, int w, int h) 	 	Line 1078 
| | MyComponent.exe!juce::Component::setBounds(juce::Rectangle<int> r) 	 	 	 Line 1176 
| | MyComponent.exe! MyComponentAudioProcessorEditor::resized() 	 	 	 Line 1144 
| | MyComponent.exe!juce::Component::sendMovedResizedMessages(bool wasMoved, bool wasResized) 	 	 	 Line 1149 
| | MyComponent.exe!juce::Component::sendMovedResizedMessagesIfPending() 	 	 	 Line 1131 
| | MyComponent.exe!juce::Component::setBounds(int x, int y, int w, int h) 	 	 	 Line 1117 
| | MyComponent.exe!juce::Component::setBounds(juce::Rectangle<int> r) 	 	 	 Line 1176 
| | MyComponent.exe!juce::ComponentBoundsConstrainer::applyBoundsToComponent(juce::Component & component, juce::Rectangle<int> bounds) 	 	 	 Line 149 
| | MyComponent.exe!juce::ComponentBoundsConstrainer::setBoundsForComponent(juce::Component * component, juce::Rectangle<int> targetBounds, bool isStretchingTop, bool isStretchingLeft, bool isStretchingBottom, bool isStretchingRight) 	 	 	 Line 135 
| | MyComponent.exe!juce::ResizableCornerComponent::mouseDrag(const juce::MouseEvent & e) 	 	 	 Line 81 
| | MyComponent.exe!juce::Component::internalMouseDrag(juce::MouseInputSource source, juce::Point<float> relativePos, juce::Time time, float pressure, float orientation, float rotation, float tiltX, float tiltY) 	 	 	 Line 2463 
| | MyComponent.exe!juce::MouseInputSourceInternal::sendMouseDrag(juce::Component & comp, juce::Point<float> screenPos, juce::Time time) 	 	 	 Line 150 
| | MyComponent.exe!juce::MouseInputSourceInternal::setScreenPos(juce::Point<float> newScreenPos, juce::Time time, bool forceUpdate) 	 	 	 Line 284 
| | MyComponent.exe!juce::MouseInputSourceInternal::handleEvent(juce::ComponentPeer & newPeer, juce::Point<float> positionWithinPeer, juce::Time time, const juce::ModifierKeys newMods, float newPressure, float newOrientation, juce::PenDetails pen) 	 	 	 Line 326 
| | MyComponent.exe!juce::MouseInputSource::handleEvent(juce::ComponentPeer & peer, juce::Point<float> pos, __int64 time, juce::ModifierKeys mods, float pressure, float orientation, const juce::PenDetails & penDetails) 	 	 	 Line 633 
| | MyComponent.exe!juce::ComponentPeer::handleMouseEvent(juce::MouseInputSource::InputSourceType type, juce::Point<float> pos, juce::ModifierKeys newMods, float newPressure, float newOrientation, __int64 time, juce::PenDetails pen, int touchIndex) 	 	 	 Line 88 
| | MyComponent.exe!juce::HWNDComponentPeer::doMouseEvent(juce::Point<float> position, float pressure, float orientation, juce::ModifierKeys mods) 	 	 	 Line 2443 
| | MyComponent.exe!juce::HWNDComponentPeer::doMouseMove(juce::Point<float> position, bool isMouseDownEvent) 	 	 	 Line 2568 

Certainly seems odd. flags.isInsidePaintCall only gets set to true in Component::paintEntireComponent (and set to false on exit of that function), which does not seem to be part of your stack trace, although the trace does seem incomplete.

Solved
It was the JUCE watermark that goes away at some point so I was left with an invalid object in ChildrenComponents
:expressionless:

Shouldn’t this get a different exception??