vcl/osx/DragSource.cxx | 8 ++++++++ vcl/osx/salframeview.mm | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-)
New commits: commit fdd5dac96c0c7fa1050d5ec0bbb22e1078ef8556 Author: Patrick Luby <guibmac...@gmail.com> AuthorDate: Sat Jul 12 12:49:08 2025 -0400 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Jul 14 09:15:32 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 (cherry picked from commit e1a369bbfa2a56e902771aa66b15aa1832d40ec5) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187785 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> 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 7dd9b64d12ca..1ee463f31a51 100644 --- a/vcl/osx/salframeview.mm +++ b/vcl/osx/salframeview.mm @@ -1314,7 +1314,7 @@ static NSString* getCurrentSelection() if ( mpMouseEventListener != nil && [mpMouseEventListener respondsToSelector: @selector(mouseDown:)]) { - [mpMouseEventListener mouseDown: [pEvent copyWithZone: nullptr]]; + [mpMouseEventListener mouseDown: pEvent]; } s_nLastButton = MOUSE_LEFT; @@ -3152,7 +3152,7 @@ static NSString* getCurrentSelection() if ( mpMouseEventListener != nil && [mpMouseEventListener respondsToSelector: @selector(mouseDragged:)]) { - [mpMouseEventListener mouseDragged: [mpPendingMouseDraggedEvent copyWithZone: nullptr]]; + [mpMouseEventListener mouseDragged: mpPendingMouseDraggedEvent]; } s_nLastButton = MOUSE_LEFT;