Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Changes from 1 commit
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
Next Next commit
Removed retain cycle from notification center.
  • Loading branch information
gaaclarke committed Oct 11, 2019
commit 780b6766d9f0836a213b1702ec97f19b6be73ba8
3 changes: 2 additions & 1 deletion shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,13 @@ - (void)setViewController:(FlutterViewController*)viewController {
self.iosPlatformView->SetOwnerViewController(_viewController);
[self maybeSetupPlatformViewChannels];

__block FlutterEngine* blockSelf = self;
Copy link
Member

Choose a reason for hiding this comment

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

🔮 The retain cycle will be reintroduced when someone finally hits the "modernize to ARC" button without auditing all the blocks where weak memory management is expected. 🔮

Copy link
Member Author

Choose a reason for hiding this comment

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

New word, "retro-modernize"? When we move to ARC it should work as well. There is a subtle difference between __block and __weak (like how they treat primitives). For an object pointer it should behave the same. I'm more sure about that than my understanding of the addObserverForName:object:queue:usingBlock: but obviously I've been wrong before, haha.

self.flutterViewControllerWillDeallocObserver =
[[NSNotificationCenter defaultCenter] addObserverForName:FlutterViewControllerWillDealloc
object:viewController
queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification* note) {
[self notifyViewControllerDeallocated];
[blockSelf notifyViewControllerDeallocated];
}];
}

Expand Down