vcl/osx/DataFlavorMapping.cxx | 3 --- vcl/osx/a11yactionwrapper.mm | 2 +- vcl/osx/a11ywrapper.mm | 12 +++++++----- 3 files changed, 8 insertions(+), 9 deletions(-)
New commits: commit 5949c600f7ca023edeb652677426c7d3e21ad06d Author: Patrick Luby <guibmac...@gmail.com> AuthorDate: Thu May 30 17:28:41 2024 -0400 Commit: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> CommitDate: Fri May 31 13:18:30 2024 +0200 Fix some macOS memory leaks due to overretaining Objective-C objects Change-Id: If826476ad6c6692d22519f4eb0fb45621240fdbf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168203 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Reviewed-by: Patrick Luby <guibomac...@gmail.com> Tested-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> diff --git a/vcl/osx/DataFlavorMapping.cxx b/vcl/osx/DataFlavorMapping.cxx index 361e268bcd6d..ade3f48dd1ab 100644 --- a/vcl/osx/DataFlavorMapping.cxx +++ b/vcl/osx/DataFlavorMapping.cxx @@ -732,10 +732,7 @@ NSArray* DataFlavorMapper::flavorSequenceToTypesArray(const css::uno::Sequence<c const NSString* str = openOfficeToSystemFlavor(flavors[i], bNeedDummyInternalFlavor, bIsSystemClipboard); if (str != nullptr) - { - [str retain]; [array addObject: str]; - } } } diff --git a/vcl/osx/a11yactionwrapper.mm b/vcl/osx/a11yactionwrapper.mm index 77d670c958b6..f9c5089a19ea 100644 --- a/vcl/osx/a11yactionwrapper.mm +++ b/vcl/osx/a11yactionwrapper.mm @@ -61,7 +61,7 @@ [ actionNames addObject: [ AquaA11yActionWrapper nativeActionNameFor: [ CreateNSString ( [ wrapper accessibleAction ] -> getAccessibleActionDescription ( cnt ) ) autorelease ] ] ]; } } - return actionNames; + return [actionNames autorelease]; } +(void)doAction:(NSString *)action ofElement:(AquaA11yWrapper *)wrapper { diff --git a/vcl/osx/a11ywrapper.mm b/vcl/osx/a11ywrapper.mm index 15482eef2b29..9ad6f0d473bc 100644 --- a/vcl/osx/a11ywrapper.mm +++ b/vcl/osx/a11ywrapper.mm @@ -353,14 +353,15 @@ static std::ostream &operator<<(std::ostream &s, NSObject *obj) { } } } - return children; + return [children autorelease]; } else if ( [ self accessibleTable ] ) { AquaA11yTableWrapper* pTable = [self isKindOfClass: [AquaA11yTableWrapper class]] ? static_cast<AquaA11yTableWrapper*>(self) : nil; return [ AquaA11yTableWrapper childrenAttributeForElement: pTable ]; } else { + NSMutableArray * children = [ [ NSMutableArray alloc ] init ]; + try { - NSMutableArray * children = [ [ NSMutableArray alloc ] init ]; Reference< XAccessibleContext > xContext( [ self accessibleContext ] ); try { @@ -398,12 +399,13 @@ static std::ostream &operator<<(std::ostream &s, NSObject *obj) { } } - [ children autorelease ]; - return NSAccessibilityUnignoredChildren( children ); + return NSAccessibilityUnignoredChildren( [ children autorelease ] ); } catch (const Exception &) { // TODO: Log - return nil; } + + [ children autorelease ]; + return [NSArray array]; } }