vcl/osx/a11yfactory.mm | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
New commits: commit 8c6b2b507a98c325bf0d0990e160d8e520a90671 Author: Patrick Luby <plub...@neooffice.org> AuthorDate: Thu Dec 15 16:25:00 2022 -0500 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Fri Dec 16 19:42:41 2022 +0000 tdf#146765 Fix infinite recursion in -[NSView visibleRect] HACK: Adding a subview to an NSView that is not attached to an NSWindow leads to infinite recursion in the native NSViewGetVisibleRect() function. This seems to be a new behavior starting with macOS 12.6.2. In the case of tdf#146765, we end up here because -[AquaA11yWrapper childrenAttribute] is called by a wrapper that is already attached to an NSWindow. That is normal. What isn't normal is that the child wrapper's unignored accessible parent is a differnt wrapper than the caller and that different wrapper is not yet attached to an NSWindow. TODO: switch the AquaA11yWrapper class to inherit the lightweight NSAccessibilityElement class instead of the NSView class to possibly avoid the need for this hack. Change-Id: Ic6c2a60e90a154786dd7f5935582ef7d3f57584c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144329 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> (cherry picked from commit 07f9f22e68a3caebe67d89c0b209059ba40be482) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144357 Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/vcl/osx/a11yfactory.mm b/vcl/osx/a11yfactory.mm index c5aa64308010..d4b0e25047fb 100644 --- a/vcl/osx/a11yfactory.mm +++ b/vcl/osx/a11yfactory.mm @@ -166,7 +166,26 @@ static bool enabled = false; if (parent) { if ([parent isKindOfClass:[NSView class]]) { NSView *parentView = static_cast<NSView *>(parent); - [parentView addSubview:aWrapper positioned:NSWindowBelow relativeTo:nil]; + + // tdf#146765 Fix infinite recursion in -[NSView visibleRect] + // HACK: Adding a subview to an NSView that is not attached + // to an NSWindow leads to infinite recursion in the native + // NSViewGetVisibleRect() function. This seems to be a new + // behavior starting with macOS 12.6.2. + // In the case of tdf#146765, we end up here because + // -[AquaA11yWrapper childrenAttribute] is called by a + // wrapper that is already attached to an NSWindow. That is + // normal. What isn't normal is that the child wrapper's + // unignored accessible parent is a differnt wrapper than + // the caller and that different wrapper is not yet + // attached to an NSWindow. + // TODO: switch the AquaA11yWrapper class to inherit the + // lightweight NSAccessibilityElement class instead of the + // NSView class to possibly avoid the need for this hack. + NSWindow *window = [parentView window]; + SAL_WARN_IF(!window, "vcl.a11y","Can't add subview. Parent view's window is nil!"); + if (window) + [parentView addSubview:aWrapper positioned:NSWindowBelow relativeTo:nil]; } else if ([parent isKindOfClass:NSClassFromString(@"SalFrameWindow")]) { NSWindow *window = static_cast<NSWindow *>(parent); NSView *salView = [window contentView];