tdf#172731 vcl/osx: fix menu translation/title ownership/lifecycle
that caused a crash on macOS 12 dictionaryWithContentsOfFile returns an auto-release object that would need to be retained. Switch that to the explicit ownership one and keep it for later access. Initialize the NSString members before they can be caught by any autorelease by the destructor & autorelease the old mpOrigTitle when assigning a new one. Change-Id: I3d273a78d92ca50c3bb5924203eb5acdf3877969 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/207817 Reviewed-by: Patrick Luby <guibomacdev@gmail.com> Tested-by: Jenkins Reviewed-by: Dan Williams <dcbw@libreoffice.org>
This commit is contained in:
+1
-1
@@ -353,7 +353,7 @@ AquaSalInstance::AquaSalInstance()
|
||||
mpListNodeCell = [[NSButtonCell alloc] init];
|
||||
|
||||
NSString *path = [[[NSBundle mainBundle] pathForResource:@"MenuTranslations" ofType:@"plist"] autorelease];
|
||||
mpMenuTranslations = [NSDictionary dictionaryWithContentsOfFile:path];
|
||||
mpMenuTranslations = [[NSDictionary alloc] initWithContentsOfFile:path];
|
||||
|
||||
#if HAVE_FEATURE_SKIA
|
||||
AquaSkiaSalGraphicsImpl::prepareSkia();
|
||||
|
||||
@@ -974,6 +974,8 @@ AquaSalMenuItem::AquaSalMenuItem( const SalItemParams* pItemData, NSDictionary *
|
||||
mpParentMenu( nullptr ),
|
||||
mpSubMenu( nullptr ),
|
||||
mpMenuItem( nil ),
|
||||
mpOrigTitle( nil ),
|
||||
mpAltTitle( nil ),
|
||||
mpMenuTranslations( [pMenuTranslations retain] )
|
||||
{
|
||||
if (pItemData->eType == MenuItemType::SEPARATOR)
|
||||
@@ -1040,6 +1042,9 @@ void AquaSalMenuItem::setTitle(const OUString& i_rText)
|
||||
if (aText.endsWith("...", &aText))
|
||||
aText += u"\u2026";
|
||||
|
||||
// autorelease on nil should be a noop, but better be safe than sorry
|
||||
if (mpOrigTitle)
|
||||
[mpOrigTitle autorelease];
|
||||
mpOrigTitle = CreateNSString( aText );
|
||||
if ( !mpOrigTitle )
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user