Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

fixes crash when sets mouseTrackingMode before view is loaded #26576

Merged
merged 3 commits into from
Jun 4, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,9 @@ - (void)listenForMetaModifiedKeyUpEvents {
}

- (void)configureTrackingArea {
NSAssert(self.viewLoaded, @"View must be loaded before setting tracking area");
if (!self.viewLoaded) {
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What causes this to get set again when the view loads?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- (void)viewDidLoad; will call the configureTrackingArea selector

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool - maybe just mention that here in a comment? otherwise LGTM

}
if (_mouseTrackingMode != FlutterMouseTrackingModeNone && self.flutterView) {
NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved |
NSTrackingInVisibleRect | NSTrackingEnabledDuringMouseDrag;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ + (void)respondFalseForSendEvent:(const FlutterKeyEvent&)event
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]);
}
Expand Down