ResizableWindow::setContentNonOwned() causes problems with ToggleButtons

In MainWindow (inherited from juce::DocumentWindow) I delete the old MainComponent and set a new one with ResizableWindow::setContentNonOwned(pointer, true), due to loading a new project file and me creating a completely new instance of the MainComponent.

What happens is that the graphics squeeze ever so slightly in the vertical direction that it’s barely noticeable. When I try clicking juce::ToggleButtons, many of them don’t respond at all and some respond when I click buttons below them. It seems that the ToggleButtons clickable areas have moved up from where their visuals are located.

The above seems to fix itself perfectly when I manually resize the window with a mouse. But nothing I do in the code seems to fix the issue. I’ve tried calling the following in various parts of the code:

setBounds()
resized()
parentSizeChanged()
parentHierarchyChanged()
childrenChanged()

So what is going on and how to fix that issue? What is the difference between using any (or all) of the above, compared to me grabbing the window with a mouse cursor and resizing it manually?

EDIT:
I added the following lines to the code and that seems to fix the problem:

        const auto bounds = getBounds();
        setBounds(0, 0, getWidth() - 1, getHeight() - 1);
        setBounds(bounds);

But the above is really a kludge fix which makes me shudder having it in the code. I couldn’t just set the bounds once due to JUCE optimizing the non changed bound resizing away. So I had to change the size to something different and then back to its original size. I hope there is a better way around this.

Which operating system do you experience this problem on?