Jassert call in juce_ResizableWindow.class


When checking my console, I am called to the both jassert there :

void ResizableWindow::addChildComponent (Component* const child, int zOrder)

    Component::addChildComponent (child, zOrder);

void ResizableWindow::addAndMakeVisible (Component* const child, int zOrder)

    Component::addAndMakeVisible (child, zOrder);

Do you confirm it is only for debug actions visibility ?

NB : I have absolutly not modified the juce sources.

In my version Julian kindly put this in the source code…

[code]void ResizableWindow::addChildComponent (Component* const child, int zOrder)
/* Agh! You shouldn’t add components directly to a ResizableWindow - this class
manages its child components automatically, and if you add your own it’ll cause
trouble. Instead, use setContentComponent() to give it a component which
will be automatically resized and kept in the right place - then you can add
subcomponents to the content comp. See the notes for the ResizableWindow class
for more info.

   If you really know what you're doing and want to avoid this assertion, just call
   Component::addChildComponent directly.


Component::addChildComponent (child, zOrder);


Hope that helps…

they are deliberately there cause you should use setContentComponent instead. Cause the window buttons are child and so, hacking in other components may cause trouble to how the window is handled.

Better to make a generic Component of your own, add you child to it, and then add the whole Component as “content-component” of the resizable window.

I had deleted the Jul’ comments. It stands the same in my sources.

In fact i just added components to a class, that inheritates from DocumentWindows : I use setContentComponent() AND addAndMakeVisible() stuff to make a customized Documentwindow.

But I dont modify directly any Juce sources

Sounds like you are trying to add a DocumentWindow into a DocumentWindow then!

Inherit from Component and then setContentComponet on a new DocumentWindow and all should be well.


This is what I do : I anstanciate many documentwindows in a main one, to make something like MaxMSP : boxes linked each others with wires.

well, a jassert for useless ting.


[quote=“asair”]well, a jassert for useless ting.


If the assert is there, it’s there for a reason.

If you choose to ignore it, please don’t clutter up the forum with problem posts when strange things start happening in your code.

Absolutely. If you ignore that assert, you’re almost certainly going to hit trouble later…