From cdba8eb8e944bfd7e135549f83adc6cf6da317ea Mon Sep 17 00:00:00 2001 From: reuk Date: Fri, 4 Feb 2022 16:33:05 +0000 Subject: [PATCH] NSViewComponentPeer: Fix NSTrackingArea leak --- .../native/juce_mac_NSViewComponentPeer.mm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index 58205af1cdf1..b6573e5c6848 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -126,10 +126,11 @@ static constexpr int translateVirtualToAsciiKeyCode (int keyCode) noexcept | NSTrackingEnabledDuringMouseDrag | NSTrackingActiveAlways | NSTrackingInVisibleRect; - [view addTrackingArea: [[NSTrackingArea alloc] initWithRect: r - options: options - owner: view - userInfo: nil]]; + const NSUniquePtr trackingArea { [[NSTrackingArea alloc] initWithRect: r + options: options + owner: view + userInfo: nil] }; + [view addTrackingArea: trackingArea.get()]; notificationCenter = [NSNotificationCenter defaultCenter];