Wrong size calculation in DefaultDialogWindow

I researched how a dialog window resizes to its content on macOS when using native window titles. The content component defines the content size of the window. To get that right the RsizableWindow calculates the window size based on borders and title bar.

void ResizableWindow::childBoundsChanged (Component* child)
{
    if ((child == contentComponent) && (child != nullptr) && resizeToFitContent)
    {
        auto borders = getContentComponentBorder();
        setSize (child->getWidth() + borders.getLeftAndRight(), child->getHeight() + borders.getTopAndBottom());
    }
}

While this is correct for the case where Juce provides the title bar, it is not when the peer provides the title base, because that is done by the peer as well:

[window setFrame: [window frameRectForContentRect: flippedScreenRect (r)] display: false];

Unless I have overlooked something, this seems to be a bug in Juce, which makes my dialog window larger that the content component.

[edit]
Turns out, it is problem specific to DialogWindow::LaunchOptions o;
The order in DefaultDialogWindow is wrong. When the window is created, setUsingNativeTitleBar is not called yet, and therefore the border is added twice, once by the toplevelwindow and once by the peer.

I reversed the order and now it works as expected:

DefaultDialogWindow (LaunchOptions& options)
    : DialogWindow (options.dialogTitle, options.dialogBackgroundColour,
                    options.escapeKeyTriggersCloseButton, true,
                    options.componentToCentreAround != nullptr
                        ? Component::getApproximateScaleFactorForComponent (options.componentToCentreAround)
                            : 1.0f)
{
    setResizable (options.resizable, options.useBottomRightCornerResizer);

	setUsingNativeTitleBar (options.useNativeTitleBar);
	setAlwaysOnTop (WindowUtils::areThereAnyAlwaysOnTopWindows());

	if (options.content.willDeleteObject())
        setContentOwned (options.content.release(), true);
    else
        setContentNonOwned (options.content.release(), true);

    centreAroundComponent (options.componentToCentreAround, getWidth(), getHeight());
}