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

Commit 6244d76

Browse files
author
Casey Hillers
authored
[release] Revert "Migrate darwin common "framework_shared" target to ARC (#37049)" (#37195)
* Revert "Use iOS 16 APIs to rotate orientation (#36874)" (#37165) * Revert "Migrate darwin common "framework_shared" target to ARC (#37049)" This reverts commit 866b670.
1 parent 72418b7 commit 6244d76

File tree

7 files changed

+134
-79
lines changed

7 files changed

+134
-79
lines changed

shell/platform/darwin/BUILD.gn

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,6 @@ source_set("flutter_channels") {
2626
sources = [
2727
"common/buffer_conversions.h",
2828
"common/buffer_conversions.mm",
29-
]
30-
31-
deps = [ "//flutter/fml" ]
32-
33-
public_deps = [ ":flutter_channels_arc" ]
34-
35-
public_configs = [ "//flutter:config" ]
36-
}
37-
38-
source_set("flutter_channels_arc") {
39-
cflags_objc = flutter_cflags_objc_arc
40-
cflags_objcc = flutter_cflags_objcc_arc
41-
42-
sources = [
4329
"common/framework/Headers/FlutterBinaryMessenger.h",
4430
"common/framework/Headers/FlutterChannels.h",
4531
"common/framework/Headers/FlutterCodecs.h",
@@ -50,12 +36,13 @@ source_set("flutter_channels_arc") {
5036
"common/framework/Source/FlutterStandardCodec_Internal.h",
5137
]
5238

53-
public = [
54-
"common/framework/Headers/FlutterBinaryMessenger.h",
55-
"common/framework/Headers/FlutterChannels.h",
56-
"common/framework/Headers/FlutterCodecs.h",
57-
"common/framework/Headers/FlutterMacros.h",
58-
"common/framework/Source/FlutterStandardCodec_Internal.h",
39+
deps = [
40+
"//flutter/common",
41+
"//flutter/flow",
42+
"//flutter/fml",
43+
"//flutter/runtime",
44+
"//flutter/shell/common",
45+
"//third_party/skia",
5946
]
6047

6148
public_configs = [ "//flutter:config" ]

shell/platform/darwin/common/BUILD.gn

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@ source_set("common") {
1616
"command_line.mm",
1717
]
1818

19-
deps = [ "//flutter/fml" ]
19+
deps = [
20+
"//flutter/common",
21+
"//flutter/flow",
22+
"//flutter/fml",
23+
"//flutter/runtime",
24+
"//flutter/shell/common",
25+
"//third_party/dart/runtime:dart_api",
26+
"//third_party/skia",
27+
]
2028

2129
public_configs = [ "//flutter:config" ]
2230
}
@@ -30,8 +38,8 @@ config("framework_relative_headers") {
3038

3139
# Framework code shared between iOS and macOS.
3240
source_set("framework_shared") {
33-
cflags_objc = flutter_cflags_objc_arc
34-
cflags_objcc = flutter_cflags_objcc_arc
41+
cflags_objc = flutter_cflags_objc
42+
cflags_objcc = flutter_cflags_objcc
3543

3644
sources = [
3745
"framework/Source/FlutterChannels.mm",

shell/platform/darwin/common/framework/Headers/FlutterCodecs.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,17 +344,17 @@ FLUTTER_DARWIN_EXPORT
344344
/**
345345
* The type of the encoded values.
346346
*/
347-
@property(readonly, nonatomic, assign) FlutterStandardDataType type;
347+
@property(readonly, nonatomic) FlutterStandardDataType type;
348348

349349
/**
350350
* The number of value items encoded.
351351
*/
352-
@property(readonly, nonatomic, assign) UInt32 elementCount;
352+
@property(readonly, nonatomic) UInt32 elementCount;
353353

354354
/**
355355
* The number of bytes used by the encoding of a single value item.
356356
*/
357-
@property(readonly, nonatomic, assign) UInt8 elementSize;
357+
@property(readonly, nonatomic) UInt8 elementSize;
358358
@end
359359

360360
/**

shell/platform/darwin/common/framework/Source/FlutterChannels.mm

Lines changed: 65 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterChannels.h"
66

7-
FLUTTER_ASSERT_ARC
8-
97
#pragma mark - Basic message channel
108

119
static NSString* const kFlutterChannelBuffersChannel = @"dev.flutter/channel-buffers";
@@ -53,9 +51,9 @@ + (instancetype)messageChannelWithName:(NSString*)name
5351
+ (instancetype)messageChannelWithName:(NSString*)name
5452
binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger
5553
codec:(NSObject<FlutterMessageCodec>*)codec {
56-
return [[FlutterBasicMessageChannel alloc] initWithName:name
57-
binaryMessenger:messenger
58-
codec:codec];
54+
return [[[FlutterBasicMessageChannel alloc] initWithName:name
55+
binaryMessenger:messenger
56+
codec:codec] autorelease];
5957
}
6058

6159
- (instancetype)initWithName:(NSString*)name
@@ -71,13 +69,21 @@ - (instancetype)initWithName:(NSString*)name
7169
taskQueue:(NSObject<FlutterTaskQueue>*)taskQueue {
7270
self = [super init];
7371
NSAssert(self, @"Super init cannot be nil");
74-
_name = [name copy];
75-
_messenger = messenger;
76-
_codec = codec;
77-
_taskQueue = taskQueue;
72+
_name = [name retain];
73+
_messenger = [messenger retain];
74+
_codec = [codec retain];
75+
_taskQueue = [taskQueue retain];
7876
return self;
7977
}
8078

79+
- (void)dealloc {
80+
[_name release];
81+
[_messenger release];
82+
[_codec release];
83+
[_taskQueue release];
84+
[super dealloc];
85+
}
86+
8187
- (void)sendMessage:(id)message {
8288
[_messenger sendOnChannel:_name message:[_codec encode:message]];
8389
}
@@ -102,7 +108,7 @@ - (void)setMessageHandler:(FlutterMessageHandler)handler {
102108
return;
103109
}
104110
// Grab reference to avoid retain on self.
105-
__weak NSObject<FlutterMessageCodec>* codec = _codec;
111+
NSObject<FlutterMessageCodec>* codec = _codec;
106112
FlutterBinaryMessageHandler messageHandler = ^(NSData* message, FlutterBinaryReply callback) {
107113
handler([codec decode:message], ^(id reply) {
108114
callback([codec encode:reply]);
@@ -122,19 +128,26 @@ - (void)resizeChannelBuffer:(NSInteger)newSize {
122128
////////////////////////////////////////////////////////////////////////////////
123129
@implementation FlutterError
124130
+ (instancetype)errorWithCode:(NSString*)code message:(NSString*)message details:(id)details {
125-
return [[FlutterError alloc] initWithCode:code message:message details:details];
131+
return [[[FlutterError alloc] initWithCode:code message:message details:details] autorelease];
126132
}
127133

128134
- (instancetype)initWithCode:(NSString*)code message:(NSString*)message details:(id)details {
129135
NSAssert(code, @"Code cannot be nil");
130136
self = [super init];
131137
NSAssert(self, @"Super init cannot be nil");
132-
_code = [code copy];
133-
_message = [message copy];
134-
_details = details;
138+
_code = [code retain];
139+
_message = [message retain];
140+
_details = [details retain];
135141
return self;
136142
}
137143

144+
- (void)dealloc {
145+
[_code release];
146+
[_message release];
147+
[_details release];
148+
[super dealloc];
149+
}
150+
138151
- (BOOL)isEqual:(id)object {
139152
if (self == object) {
140153
return YES;
@@ -156,18 +169,24 @@ - (NSUInteger)hash {
156169
////////////////////////////////////////////////////////////////////////////////
157170
@implementation FlutterMethodCall
158171
+ (instancetype)methodCallWithMethodName:(NSString*)method arguments:(id)arguments {
159-
return [[FlutterMethodCall alloc] initWithMethodName:method arguments:arguments];
172+
return [[[FlutterMethodCall alloc] initWithMethodName:method arguments:arguments] autorelease];
160173
}
161174

162175
- (instancetype)initWithMethodName:(NSString*)method arguments:(id)arguments {
163176
NSAssert(method, @"Method name cannot be nil");
164177
self = [super init];
165178
NSAssert(self, @"Super init cannot be nil");
166-
_method = [method copy];
167-
_arguments = arguments;
179+
_method = [method retain];
180+
_arguments = [arguments retain];
168181
return self;
169182
}
170183

184+
- (void)dealloc {
185+
[_method release];
186+
[_arguments release];
187+
[super dealloc];
188+
}
189+
171190
- (BOOL)isEqual:(id)object {
172191
if (self == object) {
173192
return YES;
@@ -205,7 +224,8 @@ + (instancetype)methodChannelWithName:(NSString*)name
205224
+ (instancetype)methodChannelWithName:(NSString*)name
206225
binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger
207226
codec:(NSObject<FlutterMethodCodec>*)codec {
208-
return [[FlutterMethodChannel alloc] initWithName:name binaryMessenger:messenger codec:codec];
227+
return [[[FlutterMethodChannel alloc] initWithName:name binaryMessenger:messenger
228+
codec:codec] autorelease];
209229
}
210230

211231
- (instancetype)initWithName:(NSString*)name
@@ -220,13 +240,21 @@ - (instancetype)initWithName:(NSString*)name
220240
taskQueue:(NSObject<FlutterTaskQueue>*)taskQueue {
221241
self = [super init];
222242
NSAssert(self, @"Super init cannot be nil");
223-
_name = [name copy];
224-
_messenger = messenger;
225-
_codec = codec;
226-
_taskQueue = taskQueue;
243+
_name = [name retain];
244+
_messenger = [messenger retain];
245+
_codec = [codec retain];
246+
_taskQueue = [taskQueue retain];
227247
return self;
228248
}
229249

250+
- (void)dealloc {
251+
[_name release];
252+
[_messenger release];
253+
[_codec release];
254+
[_taskQueue release];
255+
[super dealloc];
256+
}
257+
230258
- (void)invokeMethod:(NSString*)method arguments:(id)arguments {
231259
FlutterMethodCall* methodCall = [FlutterMethodCall methodCallWithMethodName:method
232260
arguments:arguments];
@@ -257,7 +285,7 @@ - (void)setMethodCallHandler:(FlutterMethodCallHandler)handler {
257285
return;
258286
}
259287
// Make sure the block captures the codec, not self.
260-
__weak NSObject<FlutterMethodCodec>* codec = _codec;
288+
NSObject<FlutterMethodCodec>* codec = _codec;
261289
FlutterBinaryMessageHandler messageHandler = ^(NSData* message, FlutterBinaryReply callback) {
262290
FlutterMethodCall* call = [codec decodeMethodCall:message];
263291
handler(call, ^(id result) {
@@ -300,7 +328,8 @@ + (instancetype)eventChannelWithName:(NSString*)name
300328
+ (instancetype)eventChannelWithName:(NSString*)name
301329
binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger
302330
codec:(NSObject<FlutterMethodCodec>*)codec {
303-
return [[FlutterEventChannel alloc] initWithName:name binaryMessenger:messenger codec:codec];
331+
return [[[FlutterEventChannel alloc] initWithName:name binaryMessenger:messenger
332+
codec:codec] autorelease];
304333
}
305334

306335
- (instancetype)initWithName:(NSString*)name
@@ -315,13 +344,21 @@ - (instancetype)initWithName:(NSString*)name
315344
taskQueue:(NSObject<FlutterTaskQueue>* _Nullable)taskQueue {
316345
self = [super init];
317346
NSAssert(self, @"Super init cannot be nil");
318-
_name = [name copy];
319-
_messenger = messenger;
320-
_codec = codec;
321-
_taskQueue = taskQueue;
347+
_name = [name retain];
348+
_messenger = [messenger retain];
349+
_codec = [codec retain];
350+
_taskQueue = [taskQueue retain];
322351
return self;
323352
}
324353

354+
- (void)dealloc {
355+
[_name release];
356+
[_codec release];
357+
[_messenger release];
358+
[_taskQueue release];
359+
[super dealloc];
360+
}
361+
325362
static FlutterBinaryMessengerConnection SetStreamHandlerMessageHandlerOnChannel(
326363
NSObject<FlutterStreamHandler>* handler,
327364
NSString* name,

shell/platform/darwin/common/framework/Source/FlutterCodecs.mm

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
#include <cstring>
88

9-
FLUTTER_ASSERT_ARC
10-
119
@implementation FlutterBinaryCodec
1210
+ (instancetype)sharedInstance {
1311
static id _sharedInstance = nil;
@@ -50,7 +48,7 @@ - (NSString*)decode:(NSData*)message {
5048
if (message == nil) {
5149
return nil;
5250
}
53-
return [[NSString alloc] initWithData:message encoding:NSUTF8StringEncoding];
51+
return [[[NSString alloc] initWithData:message encoding:NSUTF8StringEncoding] autorelease];
5452
}
5553
@end
5654

0 commit comments

Comments
 (0)