fixes crash when sets mouseTrackingMode before view is loaded (flutter/engine#26576)
This commit is contained in:
@@ -396,7 +396,11 @@ static void CommonInit(FlutterViewController* controller) {
|
||||
}
|
||||
|
||||
- (void)configureTrackingArea {
|
||||
NSAssert(self.viewLoaded, @"View must be loaded before setting tracking area");
|
||||
if (!self.viewLoaded) {
|
||||
// The viewDidLoad will call configureTrackingArea again when
|
||||
// the view is actually loaded.
|
||||
return;
|
||||
}
|
||||
if (_mouseTrackingMode != FlutterMouseTrackingModeNone && self.flutterView) {
|
||||
NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved |
|
||||
NSTrackingInVisibleRect | NSTrackingEnabledDuringMouseDrag;
|
||||
|
||||
@@ -140,6 +140,16 @@ TEST(FlutterViewController, SetsFlutterViewFirstResponderWhenAccessibilityDisabl
|
||||
EXPECT_EQ([window firstResponder], viewController.flutterView);
|
||||
}
|
||||
|
||||
TEST(FlutterViewController, CanSetMouseTrackingModeBeforeViewLoaded) {
|
||||
NSString* fixtures = @(testing::GetFixturesPath());
|
||||
FlutterDartProject* project = [[FlutterDartProject alloc]
|
||||
initWithAssetsPath:fixtures
|
||||
ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]];
|
||||
FlutterViewController* viewController = [[FlutterViewController alloc] initWithProject:project];
|
||||
viewController.mouseTrackingMode = FlutterMouseTrackingModeInActiveApp;
|
||||
ASSERT_EQ(viewController.mouseTrackingMode, FlutterMouseTrackingModeInActiveApp);
|
||||
}
|
||||
|
||||
TEST(FlutterViewControllerTest, TestKeyEventsAreSentToFramework) {
|
||||
ASSERT_TRUE([[FlutterViewControllerTestObjC alloc] testKeyEventsAreSentToFramework]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user