Browse Source
Add parent/automationPeer null guards on AvnWindow (#19805)
* Add parent/automationPeer null guards on AvnWindow
* Add null guards on AvnView
pull/19808/head
Jumar Macato
11 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
20 additions and
6 deletions
-
native/Avalonia.Native/src/OSX/AvnView.mm
-
native/Avalonia.Native/src/OSX/AvnWindow.mm
|
|
|
@ -943,7 +943,7 @@ static void ConvertTilt(NSPoint tilt, float* xTilt, float* yTilt) |
|
|
|
auto window = (AvnWindow*)[self window]; |
|
|
|
auto peer = [window automationPeer]; |
|
|
|
|
|
|
|
if (!peer->IsRootProvider()) |
|
|
|
if (peer == nullptr || !peer->IsRootProvider()) |
|
|
|
return nil; |
|
|
|
|
|
|
|
auto clientPoint = [window convertPointFromScreen:point]; |
|
|
|
@ -980,6 +980,10 @@ static void ConvertTilt(NSPoint tilt, float* xTilt, float* yTilt) |
|
|
|
// of the AvnView. |
|
|
|
auto window = (AvnWindow*)[self window]; |
|
|
|
auto peer = [window automationPeer]; |
|
|
|
if (peer == nullptr) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
auto childPeers = peer->GetChildren(); |
|
|
|
auto childCount = childPeers != nullptr ? childPeers->GetCount() : 0; |
|
|
|
|
|
|
|
|
|
|
|
@ -605,21 +605,30 @@ |
|
|
|
|
|
|
|
- (id _Nullable) accessibilityFocusedUIElement |
|
|
|
{ |
|
|
|
if (![self automationPeer]->IsRootProvider()) |
|
|
|
auto automationPeer = [self automationPeer]; |
|
|
|
if (automationPeer == nullptr || !automationPeer->IsRootProvider()) |
|
|
|
return nil; |
|
|
|
auto focusedPeer = [self automationPeer]->RootProvider_GetFocus(); |
|
|
|
|
|
|
|
auto focusedPeer = automationPeer->RootProvider_GetFocus(); |
|
|
|
if (focusedPeer == nullptr) |
|
|
|
return nil; |
|
|
|
|
|
|
|
return [AvnAccessibilityElement acquire:focusedPeer]; |
|
|
|
} |
|
|
|
|
|
|
|
- (NSString * _Nullable) accessibilityIdentifier |
|
|
|
{ |
|
|
|
return GetNSStringAndRelease([self automationPeer]->GetAutomationId()); |
|
|
|
auto automationPeer = [self automationPeer]; |
|
|
|
if (automationPeer == nullptr) |
|
|
|
return nil; |
|
|
|
|
|
|
|
return GetNSStringAndRelease(automationPeer->GetAutomationId()); |
|
|
|
} |
|
|
|
|
|
|
|
- (IAvnAutomationPeer* _Nonnull) automationPeer |
|
|
|
{ |
|
|
|
auto parent = _parent.tryGet(); |
|
|
|
if (_automationPeer == nullptr) |
|
|
|
if (parent && _automationPeer == nullptr) |
|
|
|
{ |
|
|
|
_automationPeer = parent->BaseEvents->GetAutomationPeer(); |
|
|
|
_automationNode = new AvnAutomationNode(self); |
|
|
|
@ -632,7 +641,8 @@ |
|
|
|
- (void)raiseChildrenChanged |
|
|
|
{ |
|
|
|
auto parent = _parent.tryGet(); |
|
|
|
[parent->View raiseAccessibilityChildrenChanged]; |
|
|
|
if(parent) |
|
|
|
[parent->View raiseAccessibilityChildrenChanged]; |
|
|
|
} |
|
|
|
|
|
|
|
- (void)raiseFocusChanged |
|
|
|
|