diff --git a/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm b/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm index 01ab9d31ec57..e2412c9e2c70 100644 --- a/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm +++ b/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm @@ -199,10 +199,12 @@ void removeFromParent() { if (view != getView()) { - attachment = nullptr; + ReferenceCountedObject* object = nullptr; if (view != nullptr) - attachment = attachViewToComponent (*this, view); + object = attachViewToComponent (*this, view); + + attachment = object; } }