[Windows] Fix FlutterWindow::GetNativeViewAccessible crash (flutter/engine#43368)
Flutter shouldn't crash if a view's `HWND` receives a `WM_GETOBJECT` message before it is attached to the view. Fixes https://github.com/flutter/flutter/issues/129791 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
@@ -279,6 +279,10 @@ bool FlutterWindow::OnBitmapSurfaceUpdated(const void* allocation,
|
||||
}
|
||||
|
||||
gfx::NativeViewAccessible FlutterWindow::GetNativeViewAccessible() {
|
||||
if (binding_handler_delegate_ == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return binding_handler_delegate_->GetNativeViewAccessible();
|
||||
}
|
||||
|
||||
|
||||
@@ -272,6 +272,15 @@ TEST(FlutterWindowTest, OnThemeChange) {
|
||||
win32window.InjectWindowMessage(WM_THEMECHANGED, 0, 0);
|
||||
}
|
||||
|
||||
// The window should return no root accessibility node if
|
||||
// it isn't attached to a view.
|
||||
// Regression test for https://github.com/flutter/flutter/issues/129791
|
||||
TEST(FlutterWindowTest, AccessibilityNodeWithoutView) {
|
||||
MockFlutterWindow win32window;
|
||||
|
||||
EXPECT_EQ(win32window.GetNativeViewAccessible(), nullptr);
|
||||
}
|
||||
|
||||
TEST(FlutterWindowTest, InitialAccessibilityFeatures) {
|
||||
MockFlutterWindow win32window;
|
||||
MockWindowBindingHandlerDelegate delegate;
|
||||
|
||||
Reference in New Issue
Block a user