summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2012-09-26 13:42:54 +0300
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-09-27 11:17:42 -0400
commit50a72d18900a7faf01ab176bef04dc880f59317a (patch)
tree3200370e3ca7956bfdaf16408cf030c62160b013 /vcl
parentb04ffe037117c35ebd05b41569379e8acded4fbc (diff)
Fix crash on Mac when a11y in use, and avoid infinite loop, fdo#47275
The code used static_cast blindly even if the object not necessarily was of the assumed subclass. Crash followed. Use dynamic_cast instead to be able to check, like the corresponding code for GTK a11y. After that fix we then got a nice infinite loop whn an object apparently is its own parent. Detect that and break out. Whether accessibility for the affected parts of the GUI actually works now for its real use cases, no idea. But anything is better than a crash... Change-Id: I862234e168db0bd19d185b0f1f73b733b570cac4 Signed-off-by: Norbert Thiebaud <nthiebaud@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/aqua/source/a11y/aqua11yfocustracker.cxx15
-rw-r--r--vcl/aqua/source/a11y/aqua11ywrapper.mm7
2 files changed, 20 insertions, 2 deletions
diff --git a/vcl/aqua/source/a11y/aqua11yfocustracker.cxx b/vcl/aqua/source/a11y/aqua11yfocustracker.cxx
index 822b2b498c99..3bb11688d107 100644
--- a/vcl/aqua/source/a11y/aqua11yfocustracker.cxx
+++ b/vcl/aqua/source/a11y/aqua11yfocustracker.cxx
@@ -81,7 +81,20 @@ long AquaA11yFocusTracker::WindowEventHandler(AquaA11yFocusTracker *pFocusTracke
pFocusTracker->tabpage_activated( getWindow(pEvent) );
break;
case VCLEVENT_MENU_HIGHLIGHT:
- pFocusTracker->menu_highlighted( static_cast < const VclMenuEvent * > (pEvent) );
+ // Inspired by code in WindowEventHandler in
+ // vcl/unx/gtk/a11y/atkutil.cxx, find out what kind of event
+ // it is to avoid blindly using a static_cast and crash,
+ // fdo#47275.
+ if( const VclMenuEvent* pMenuEvent = dynamic_cast < const VclMenuEvent* > (pEvent) )
+ {
+ pFocusTracker->menu_highlighted( pMenuEvent );
+ }
+ else if( const VclAccessibleEvent* pAccEvent = dynamic_cast < const VclAccessibleEvent* > (pEvent) )
+ {
+ Reference< XAccessible > xAccessible = pAccEvent->GetAccessible();
+ if( xAccessible.is() )
+ pFocusTracker->setFocusedObject( xAccessible );
+ }
break;
default:
break;
diff --git a/vcl/aqua/source/a11y/aqua11ywrapper.mm b/vcl/aqua/source/a11y/aqua11ywrapper.mm
index 9f4e55e408a0..2398e82a0fdb 100644
--- a/vcl/aqua/source/a11y/aqua11ywrapper.mm
+++ b/vcl/aqua/source/a11y/aqua11ywrapper.mm
@@ -379,7 +379,12 @@ static BOOL isPopupMenuOpen = NO;
// go upstairs until reaching the broken connection
AquaA11yWrapper * aWrapper = self;
while ( [ aWrapper accessibleContext ] -> getAccessibleParent().is() ) {
- aWrapper = [ AquaA11yFactory wrapperForAccessibleContext: [ aWrapper accessibleContext ] -> getAccessibleParent() -> getAccessibleContext() ];
+ AquaA11yWrapper *aTentativeParentWrapper = [ AquaA11yFactory wrapperForAccessibleContext: [ aWrapper accessibleContext ] -> getAccessibleParent() -> getAccessibleContext() ];
+ // Quick-and-dirty fix for infinite loop after fixing crash in
+ // fdo#47275
+ if ( aTentativeParentWrapper == aWrapper )
+ break;
+ aWrapper = aTentativeParentWrapper;
[ aWrapper autorelease ];
}
// get associated NSWindow