TextButtons won't show?

I’m populating an OwnedArray with TextButton pointers in the PluginEditor constructor only for them to apparently all be deleted by the time resized() is called. Is resized() being called before PluginEditor is created, for some reason? Or is there a semantic of OwnedArray I’m missing?

In the code, the array I’m concerned about is muteBtns used in the constructor and resized(): https://github.com/NebuHiiEjamu/CinemixAutomationBridge/blob/master/AutomationBridgeNew/Source/PluginEditor.cpp

This line looks suspicious to me:

addAndMakeVisible (dynamic_cast<Component*> (muteBtn));

I’ve never had to cast any Component to the base class for addAndMakeVisible(). I’m no expert, but could that be the problem? Doesn’t this work?

addAndMakeVisible (muteBtn);

The rest of it looks OK on first glance…

1 Like

I’ll try that and report back.

Although, since addAndMakeVisible() is a method of the base class anyway, it probably has nothing to do with it… It may take better eyes than mine to see the problem! :slight_smile:

Yes, the dynamic_cast shouldn’t be there at all. But it doesn’t do anything in this particular case.

The setSize() call triggers resized(). Since your setSize() call occurs at the beginning, the resized has nothing to layout. If you look at the size of muteBtns it will show 0.

If you move the setSize() to the end of the constructor after all the child components are constructed, it should be better.

(The original comment above setSize() even says that :wink: )