-
Notifications
You must be signed in to change notification settings - Fork 6k
Migrate darwin common "framework_shared" target to ARC #37049
Changes from 2 commits
425aea4
3f5368c
a92065a
1265796
3f8c2fb
7b6a5a4
6157ddf
35559e1
ea06e4e
1fde705
700da71
0dd00d5
12a7fd7
0a5aec4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -51,9 +51,9 @@ + (instancetype)messageChannelWithName:(NSString*)name | |||||||||||||
| + (instancetype)messageChannelWithName:(NSString*)name | ||||||||||||||
| binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger | ||||||||||||||
| codec:(NSObject<FlutterMessageCodec>*)codec { | ||||||||||||||
| return [[[FlutterBasicMessageChannel alloc] initWithName:name | ||||||||||||||
| binaryMessenger:messenger | ||||||||||||||
| codec:codec] autorelease]; | ||||||||||||||
| return [[FlutterBasicMessageChannel alloc] initWithName:name | ||||||||||||||
| binaryMessenger:messenger | ||||||||||||||
| codec:codec]; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| - (instancetype)initWithName:(NSString*)name | ||||||||||||||
|
|
@@ -69,21 +69,13 @@ - (instancetype)initWithName:(NSString*)name | |||||||||||||
| taskQueue:(NSObject<FlutterTaskQueue>*)taskQueue { | ||||||||||||||
| self = [super init]; | ||||||||||||||
| NSAssert(self, @"Super init cannot be nil"); | ||||||||||||||
| _name = [name retain]; | ||||||||||||||
| _messenger = [messenger retain]; | ||||||||||||||
| _codec = [codec retain]; | ||||||||||||||
| _taskQueue = [taskQueue retain]; | ||||||||||||||
| _name = name; | ||||||||||||||
|
||||||||||||||
| _name = name; | |
| _name = [name copy]; |
Also all the FlutterBasicMessageChannel ivars should be properties... but that doesn't need to be done here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong, codec needs to be captured by the block to live longer than the channel object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe just early return if codec is nil? if codec is nil, should this handler be called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't looked into the implementation details. But just looking at this method without context, the behavior is different if we early return when codec is nil. The current behavior is that the handler is always called regardless of the codec's value. So I'd say we should keep it the same behavior and maybe update the code later if we think that's a bug.
Edit: we probably shouldn't even support a nil codec, maybe we can add an FML_DCHECK. But it is probably a good idea doing it in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed there's not real-world case where a nil codec makes sense. Asserting it's not nil sgtm in a followup patch.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And these properties are copy but you only get that on the property setter, not when you set the synthesized ivar.
| _code = code; | |
| _message = message; | |
| _details = details; | |
| _code = [code copy]; | |
| _message = [message copy]; | |
| _details = [details copy]; |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| _method = method; | |
| _method = [method copy]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same q here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong, codec needs to be captured by the block to live longer than the channel object. _codec was actually nil in some scenarios if not captured strongly.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
etc
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically it is a breaking change.
Though I don't think making it a "copy" is going to change the way the public API is actually used unless it was abused where someone intentionally make it mutable?
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's readonly, the setter is not synthesized, so it's not a breaking change here.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The breaking part I'm talking about is when someone assigns it to a MutableString, then changes the mutableString and this property will be changed.
So it was originally a bug. By "breaking". I meant if someone is abusing this bug to update the value of these properties, their code will stop working.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After another look, I realized I was mixing stuff in my head. I think @hellohuanlin was right. And in addition, since the setters are not synthesized, copy doesn't even make sense here. I will revert these changes.