Skip to content

Commit 7fc4c29

Browse files
authored
[camera] Fix crash when setting activeFormat on FLTCaptureDevice (#8630)
Fixes flutter/flutter#163295. Unfortunately Obj-C didn't provide any compile-time safety check for that.
1 parent b63ca43 commit 7fc4c29

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

packages/camera/camera_avfoundation/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.9.18+7
2+
3+
* Fixes crash when setting `activeFormat` on `FLTCaptureDevice`.
4+
15
## 0.9.18+6
26

37
* Refactors implementations to remove remaining usage of OCMock in internal testing.

packages/camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/FLTCaptureDevice.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ - (AVCaptureDevicePosition)position {
4444
return wrappedFormats;
4545
}
4646

47-
- (void)setActiveFormat:(AVCaptureDeviceFormat *)format {
48-
self.device.activeFormat = format;
47+
- (void)setActiveFormat:(NSObject<FLTCaptureDeviceFormat> *)format {
48+
self.device.activeFormat = format.format;
4949
}
5050

5151
// Flash/Torch

packages/camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/FLTCaptureDevice.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ NS_ASSUME_NONNULL_BEGIN
2525
- (AVCaptureDevicePosition)position;
2626

2727
// Format/Configuration
28-
- (NSObject<FLTCaptureDeviceFormat> *)activeFormat;
29-
- (NSArray<NSObject<FLTCaptureDeviceFormat> *> *)formats;
30-
- (void)setActiveFormat:(NSObject<FLTCaptureDeviceFormat> *)format;
28+
@property(nonatomic, retain) NSObject<FLTCaptureDeviceFormat> *activeFormat;
29+
@property(nonatomic, readonly) NSArray<NSObject<FLTCaptureDeviceFormat> *> *formats;
3130

3231
// Flash/Torch
3332
- (BOOL)hasFlash;

packages/camera/camera_avfoundation/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: camera_avfoundation
22
description: iOS implementation of the camera plugin.
33
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_avfoundation
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
5-
version: 0.9.18+6
5+
version: 0.9.18+7
66

77
environment:
88
sdk: ^3.4.0

0 commit comments

Comments
 (0)