diff --git a/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm b/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm index 01ab9d31ec..2fcf0e047d 100644 --- a/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm +++ b/modules/juce_gui_extra/native/juce_mac_NSViewComponent.mm @@ -177,6 +177,7 @@ public: NSView* const view; + typedef ReferenceCountedObjectPtr Ptr; private: Component& owner; ComponentPeer* currentPeer; @@ -199,10 +200,14 @@ void NSViewComponent::setView (void* const view) { if (view != getView()) { + NSViewAttachment::Ptr old = attachment; + attachment = nullptr; if (view != nullptr) attachment = attachViewToComponent (*this, view); + + old = nullptr; } }