File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ## 9.3.0
2+ - ` autoReleasePool ` now returns the value produced by its callback.
3+
14## 9.2.5
25- Fix a [ bug] ( https://github.com/dart-lang/native/issues/3011 ) by adding
36 minimum OS version flags to the build script.
Original file line number Diff line number Diff line change @@ -35,10 +35,10 @@ import 'runtime_bindings_generated.dart';
3535/// here (the [Future] it returns will not be awaited). Objective-C autorelease
3636/// pools form a strict stack, and allowing async execution gaps inside the pool
3737/// scope could easily break this nesting, so async functions are not supported.
38- void autoReleasePool ( void Function () function) {
38+ T autoReleasePool < T >( T Function () function) {
3939 final pool = autoreleasePoolPush ();
4040 try {
41- function ();
41+ return function ();
4242 } finally {
4343 autoreleasePoolPop (pool);
4444 }
Original file line number Diff line number Diff line change 44
55name : objective_c
66description : ' A library to access Objective C from Flutter that acts as a support library for package:ffigen.'
7- version : 9.2.5
7+ version : 9.3.0
88repository : https://github.com/dart-lang/native/tree/main/pkgs/objective_c
99issue_tracker : https://github.com/dart-lang/native/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aobjective_c
1010
Original file line number Diff line number Diff line change @@ -56,5 +56,25 @@ void main() {
5656
5757 expect (objectRetainCount (pointer), 0 );
5858 });
59+
60+ test ('returns callback value' , () async {
61+ late Pointer <ObjCObjectImpl > pointer;
62+
63+ final returnedPointer = autoReleasePool (() {
64+ final object = NSObject ();
65+ pointer = object.ref.retainAndAutorelease ();
66+ return pointer;
67+ });
68+
69+ // Returned value should be exactly what the callback returned
70+ expect (returnedPointer, same (pointer));
71+
72+ doGC ();
73+ await Future <void >.delayed (Duration .zero);
74+ doGC ();
75+
76+ // Object should be released once the pool is popped
77+ expect (objectRetainCount (pointer), 0 );
78+ });
5979 });
6080}
You can’t perform that action at this time.
0 commit comments