vcl/osx/DragSource.cxx | 8 ++++++++ vcl/osx/salframeview.mm | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-)
New commits: commit e1a369bbfa2a56e902771aa66b15aa1832d40ec5 Author: Patrick Luby <guibmac...@gmail.com> AuthorDate: Sat Jul 12 12:49:08 2025 -0400 Commit: Patrick Luby <guibomac...@gmail.com> CommitDate: Sat Jul 12 22:17:11 2025 +0200 Fix NSEvent memory leak DragSource instances retain an NSEvent but would never release it. Also, NSEvent instances are essentially immutable since all of their properties are read only. So just retain an existing NSEvent instead of making a new copy. Change-Id: I1a13cdc04f6b8a1bede6c831a04d6e8d152b8b29 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187781 Reviewed-by: Patrick Luby <guibomac...@gmail.com> Tested-by: Jenkins diff --git a/vcl/osx/DragSource.cxx b/vcl/osx/DragSource.cxx index fbe3b216a653..0bc6eaca8681 100644 --- a/vcl/osx/DragSource.cxx +++ b/vcl/osx/DragSource.cxx @@ -156,6 +156,9 @@ DragSource::~DragSource() if( mpFrame && AquaSalFrame::isAlive( mpFrame ) ) [static_cast<id <MouseEventListener>>(mView) unregisterMouseEventListener: mDragSourceHelper]; [mDragSourceHelper release]; + + if( mLastMouseEventBeforeStartDrag ) + [mLastMouseEventBeforeStartDrag release]; } void SAL_CALL DragSource::initialize(const Sequence< Any >& aArguments) @@ -293,6 +296,11 @@ void DragSource::saveMouseEvent(NSEvent* theEvent) } mLastMouseEventBeforeStartDrag = theEvent; + + if (mLastMouseEventBeforeStartDrag != nil) + { + [mLastMouseEventBeforeStartDrag retain]; + } } /* isLocal indicates whether or not the DnD operation is OOo diff --git a/vcl/osx/salframeview.mm b/vcl/osx/salframeview.mm index e4f474b8f050..593cdbbaa8ba 100644 --- a/vcl/osx/salframeview.mm +++ b/vcl/osx/salframeview.mm @@ -1312,7 +1312,7 @@ static NSString* getCurrentSelection() if ( mpMouseEventListener != nil && [mpMouseEventListener respondsToSelector: @selector(mouseDown:)]) { - [mpMouseEventListener mouseDown: [pEvent copyWithZone: nullptr]]; + [mpMouseEventListener mouseDown: pEvent]; } s_nLastButton = MOUSE_LEFT; @@ -3150,7 +3150,7 @@ static NSString* getCurrentSelection() if ( mpMouseEventListener != nil && [mpMouseEventListener respondsToSelector: @selector(mouseDragged:)]) { - [mpMouseEventListener mouseDragged: [mpPendingMouseDraggedEvent copyWithZone: nullptr]]; + [mpMouseEventListener mouseDragged: mpPendingMouseDraggedEvent]; } s_nLastButton = MOUSE_LEFT;