Jassert call in juce_ResizableWindow.class


#1

Hello,

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

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

    Component::addChildComponent (child, zOrder);
}

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

    Component::addAndMakeVisible (child, zOrder);
}

Do you confirm it is only for debug actions visibility ?

NB : I have absolutly not modified the juce sources.


#2

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.

*/
jassertfalse

Component::addChildComponent (child, zOrder);

}[/code]

Hope that helps…


#3

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.


#4

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


#5

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.


#6

Touché,

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


#7

well, a jassert for useless ting.

Brrr


#8

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

Brrr[/quote]

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.


#9

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