[vlc-commits] macosx/messages: replace deprecated API call with modern blocks-based counterpart

Felix Paul Kühne git at videolan.org
Thu Aug 23 12:17:35 CEST 2012


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Thu Aug 23 12:04:51 2012 +0200| [adde68fa66aec080676a41d35a2070af5e26f98b] | committer: Felix Paul Kühne

macosx/messages: replace deprecated API call with modern blocks-based counterpart

Additionally, fix a leak

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=adde68fa66aec080676a41d35a2070af5e26f98b
---

 modules/gui/macosx/intf.m |   33 +++++++++++++++------------------
 1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index 5005355..ffc9528 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -2145,28 +2145,25 @@ unsigned int CocoaKeyToVLC( unichar i_key )
     [saveFolderPanel setCanSelectHiddenExtension: NO];
     [saveFolderPanel setCanCreateDirectories: YES];
     [saveFolderPanel setAllowedFileTypes: [NSArray arrayWithObject:@"rtf"]];
-    [saveFolderPanel beginSheetForDirectory:nil file: [NSString stringWithFormat: _NS("VLC Debug Log (%s).rtf"), VERSION_MESSAGE] modalForWindow: o_msgs_panel modalDelegate:self didEndSelector:@selector(saveDebugLogAsRTF:returnCode:contextInfo:) contextInfo:nil];
-}
-
-- (void)saveDebugLogAsRTF: (NSSavePanel *)sheet returnCode: (int)returnCode contextInfo: (void *)contextInfo
-{
-    if( returnCode == NSOKButton )
-    {
-        NSUInteger count = [o_msg_arr count];
-        NSMutableAttributedString * string = [[NSMutableAttributedString alloc] init];
-        for (NSUInteger i = 0; i < count; i++)
+    [saveFolderPanel setNameFieldStringValue:[NSString stringWithFormat: _NS("VLC Debug Log (%s).rtf"), VERSION_MESSAGE]];
+    [saveFolderPanel beginSheetModalForWindow: o_msgs_panel completionHandler:^(NSInteger returnCode) {
+        if( returnCode == NSOKButton )
         {
-            [string appendAttributedString: [o_msg_arr objectAtIndex: i]];
-        }
+            NSUInteger count = [o_msg_arr count];
+            NSMutableAttributedString * string = [[NSMutableAttributedString alloc] init];
+            for (NSUInteger i = 0; i < count; i++)
+                [string appendAttributedString: [o_msg_arr objectAtIndex: i]];
 
-        NSData *data = [string RTFFromRange:NSMakeRange( 0, [string length] )
-                         documentAttributes:[NSDictionary dictionaryWithObject: NSRTFTextDocumentType forKey: NSDocumentTypeDocumentAttribute]];
+            NSData *data = [string RTFFromRange:NSMakeRange( 0, [string length] )
+                             documentAttributes:[NSDictionary dictionaryWithObject: NSRTFTextDocumentType forKey: NSDocumentTypeDocumentAttribute]];
 
-        if( [data writeToFile: [[sheet URL] path] atomically: YES] == NO )
-            msg_Warn( p_intf, "Error while saving the debug log" );
+            if( [data writeToFile: [[saveFolderPanel URL] path] atomically: YES] == NO )
+                msg_Warn( p_intf, "Error while saving the debug log" );
 
-        [string release];
-    }
+            [string release];
+        }
+    }];
+    [saveFolderPanel release];
 }
 
 #pragma mark -



More information about the vlc-commits mailing list