GitToTheHub commented on code in PR #942:
URL: 
https://github.com/apache/cordova-plugin-camera/pull/942#discussion_r2688062015


##########
src/ios/CDVCamera.m:
##########
@@ -396,17 +396,29 @@ - (void)picker:(PHPickerViewController*)picker 
didFinishPicking:(NSArray<PHPicke
         
         // Check if it's a video
         if ([pickerResult.itemProvider 
hasItemConformingToTypeIdentifier:UTTypeMovie.identifier]) {
-            [pickerResult.itemProvider 
loadFileRepresentationForTypeIdentifier:UTTypeMovie.identifier 
completionHandler:^(NSURL * _Nullable url, NSError * _Nullable error) {
+            // Writes a copy of the data to a temporary file. This file will 
be deleted
+            // when the completion handler returns. The program should copy or 
move the file within the completion handler.
+            [pickerResult.itemProvider 
loadFileRepresentationForTypeIdentifier:UTTypeMovie.identifier
+                                                             
completionHandler:^(NSURL * _Nullable url, NSError * _Nullable error) {
                 if (error) {
-                    CDVPluginResult* result = [CDVPluginResult 
resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error 
localizedDescription]];
+                    CDVPluginResult* result = [CDVPluginResult 
resultWithStatus:CDVCommandStatus_ERROR
+                                                                
messageAsString:[error localizedDescription]];
                     [weakSelf.commandDelegate sendPluginResult:result 
callbackId:callbackId];
                     weakSelf.hasPendingOperation = NO;
                     return;
                 }
                 
                 dispatch_async(dispatch_get_main_queue(), ^{
                     NSString* videoPath = [weakSelf createTmpVideo:[url path]];

Review Comment:
   GPT says:
   
   - On iOS with ARC there is no GC; weak references are zeroing. If the object 
deallocates, weakSelf becomes nil. Sending Objective‑C messages to nil is a 
no‑op, not a crash.
   - The only “risk” is that weakSelf might be nil by the time the block runs, 
so the work is skipped. That’s generally acceptable (and better than a retain 
cycle).
   
   So it would not crash if `weakSelf` is `nil`. But I can add it anyway.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to