[vlc-devel] commit: memleaks: Several Mac OS X interface related memleaks. ( Derk-Jan Hartman )

git version control git at videolan.org
Sat May 30 00:32:48 CEST 2009


vlc | branch: master | Derk-Jan Hartman <hartman at videolan.org> | Thu May 28 00:16:17 2009 +0200| [275126b2770b61c77a7bbeb06392f6b76f6f0e32] | committer: Jean-Baptiste Kempf 

memleaks: Several Mac OS X interface related memleaks.
(cherry picked from commit bc3883a52ee35d2d118f8a7c43093faa253cc0b4)

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

 modules/gui/macosx/controls.m     |    4 +-
 modules/gui/macosx/playlist.m     |    1 +
 modules/gui/macosx/simple_prefs.m |   39 ++++++++++++++++++++----------------
 modules/misc/quartztext.c         |    4 ++-
 4 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/modules/gui/macosx/controls.m b/modules/gui/macosx/controls.m
index e743906..3d057ef 100644
--- a/modules/gui/macosx/controls.m
+++ b/modules/gui/macosx/controls.m
@@ -840,7 +840,7 @@
                 text_list.p_list->p_values[i].psz_string : val_list.p_list->p_values[i].psz_string ];
 
             o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""];
-            o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: strdup(psz_variable) ofObject: p_object
+            o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
                     andValue: another_val ofType: i_type];
             [o_lmi setRepresentedObject: [o_data autorelease]];
             [o_lmi setTarget: self];
@@ -858,7 +858,7 @@
                                  val_list.p_list->p_values[i].i_int];
 
             o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""];
-            o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: strdup(psz_variable) ofObject: p_object
+            o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
                     andValue: val_list.p_list->p_values[i] ofType: i_type];
             [o_lmi setRepresentedObject: [o_data autorelease]];
             [o_lmi setTarget: self];
diff --git a/modules/gui/macosx/playlist.m b/modules/gui/macosx/playlist.m
index e32e58f..40fb376 100644
--- a/modules/gui/macosx/playlist.m
+++ b/modules/gui/macosx/playlist.m
@@ -601,6 +601,7 @@
                 [o_mi_revealInFinder setEnabled: YES];
                 [o_mm_mi_revealInFinder setEnabled: YES];
             }
+            free( psz_uri );
         }
 
         if( [[VLCMain sharedInstance] isPlaylistCollapsed] == NO )
diff --git a/modules/gui/macosx/simple_prefs.m b/modules/gui/macosx/simple_prefs.m
index 5ea9c6c..0ddf9de 100644
--- a/modules/gui/macosx/simple_prefs.m
+++ b/modules/gui/macosx/simple_prefs.m
@@ -389,6 +389,13 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des
     [object setToolTip: _NS(p_item->psz_longtext)];
 }
 
+- (void)setupField:(NSTextField *)o_object forOption:(const char *)psz_option
+{
+    char *psz_tmp = config_GetPsz( p_intf, psz_option );
+    [o_object setStringValue: [NSString stringWithUTF8String: psz_tmp ?: ""]];
+    free( psz_tmp );
+}
+
 - (void)resetControls
 {
     module_config_t *p_item;
@@ -417,8 +424,7 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des
     [o_audio_spdif_ckb setState: config_GetInt( p_intf, "spdif" )];
 
     [self setupButton: o_audio_dolby_pop forIntList: "force-dolby-surround"];
-
-    [o_audio_lang_fld setStringValue: [NSString stringWithUTF8String: config_GetPsz( p_intf, "audio-language" ) ?: ""]];
+    [self setupField: o_audio_lang_fld forOption: "audio-language"];
 
     [o_audio_headphone_ckb setState: config_GetInt( p_intf, "headphone-dolby" )];
     
@@ -428,6 +434,7 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des
         [o_audio_norm_ckb setState: (NSInteger)strstr( psz_tmp, "volnorm" )];
         [o_audio_norm_fld setEnabled: [o_audio_norm_ckb state]];
         [o_audio_norm_stepper setEnabled: [o_audio_norm_ckb state]];
+        free( psz_tmp );
     }
     [o_audio_norm_fld setFloatValue: config_GetFloat( p_intf, "norm-max-level" )];
 
@@ -436,8 +443,8 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des
     /* Last.FM is optional */
     if( module_exists( "audioscrobbler" ) )
     {
-        [o_audio_lastuser_fld setStringValue: [NSString stringWithUTF8String: config_GetPsz( p_intf, "lastfm-username" ) ?: ""]];
-        [o_audio_lastpwd_sfld setStringValue: [NSString stringWithUTF8String: config_GetPsz( p_intf, "lastfm-password" ) ?: ""]];
+        [self setupField: o_audio_lastuser_fld forOption:"lastfm-username"];
+        [self setupField: o_audio_lastpwd_sfld forOption:"lastfm-password"];
 
         if( config_ExistIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ) )
         {
@@ -483,8 +490,8 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des
     [o_video_device_pop selectItemAtIndex: 0];
     [o_video_device_pop selectItemWithTag: config_GetInt( p_intf, "macosx-vdev" )];
 
-    [o_video_snap_folder_fld setStringValue: [NSString stringWithUTF8String: config_GetPsz( p_intf, "snapshot-path" ) ?: ""]];
-    [o_video_snap_prefix_fld setStringValue: [NSString stringWithUTF8String: config_GetPsz( p_intf, "snapshot-prefix" ) ?: ""]];
+    [self setupField:o_video_snap_folder_fld forOption:"snapshot-path"];
+    [self setupField:o_video_snap_prefix_fld forOption:"snapshot-prefix"];
     [o_video_snap_seqnum_ckb setState: config_GetInt( p_intf, "snapshot-sequential" )];
     [self setupButton: o_video_snap_format_pop forStringList: "snapshot-format"];
 
@@ -492,10 +499,8 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des
      * input & codecs settings *
      ***************************/
     [o_input_serverport_fld setIntValue: config_GetInt( p_intf, "server-port" )];
-    if( config_GetPsz( p_intf, "http-proxy" ) != NULL )
-        [o_input_httpproxy_fld setStringValue: [NSString stringWithUTF8String: config_GetPsz( p_intf, "http-proxy" ) ?: ""]];
-    if( config_GetPsz( p_intf, "http-proxy" ) != NULL )
-        [o_input_httpproxypwd_sfld setStringValue: [NSString stringWithUTF8String: config_GetPsz( p_intf, "http-proxy-pwd" ) ?: ""]];
+    [self setupField:o_input_httpproxy_fld forOption:"http-proxy"];
+    [self setupField:o_input_httpproxypwd_sfld forOption:"http-proxy-pwd"];
     [o_input_postproc_fld setIntValue: config_GetInt( p_intf, "postproc-q" )];
 
     [self setupButton: o_input_avi_pop forIntList: "avi-index"];
@@ -559,10 +564,8 @@ create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_des
     [o_osd_osd_ckb setState: config_GetInt( p_intf, "osd" )];
     
     [self setupButton: o_osd_encoding_pop forStringList: "subsdec-encoding"];
-    
-    [o_osd_lang_fld setStringValue: [NSString stringWithUTF8String: config_GetPsz( p_intf, "sub-language" ) ?: ""]];
-    if( config_GetPsz( p_intf, "quartztext-font" ) != NULL )
-        [o_osd_font_fld setStringValue: [NSString stringWithUTF8String: config_GetPsz( p_intf, "quartztext-font" ) ?: ""]];
+    [self setupField: o_osd_lang_fld forOption: "sub-language" ];
+    [self setupField: o_osd_font_fld forOption: "quartztext-font"];
 
     [self setupButton: o_osd_font_color_pop forIntList: "quartztext-color"];
     [self setupButton: o_osd_font_size_pop forIntList: "quartztext-rel-fontsize"];
@@ -755,6 +758,7 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch
                 /* work-around a GCC 4.0.1 bug */
                 psz_tmp = (char *)[[NSString stringWithFormat: @"%s:volnorm", psz_tmp] UTF8String];
                 config_PutPsz( p_intf, "audio-filter", psz_tmp );
+                free( psz_tmp );
             }
         }
         else
@@ -762,10 +766,11 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch
             psz_tmp = config_GetPsz( p_intf, "audio-filter" );
             if( psz_tmp )
             {
-                psz_tmp = (char *)[[[NSString stringWithUTF8String: psz_tmp] stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@":volnorm"]] UTF8String];
-                psz_tmp = (char *)[[[NSString stringWithUTF8String: psz_tmp] stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"volnorm:"]] UTF8String];
-                psz_tmp = (char *)[[[NSString stringWithUTF8String: psz_tmp] stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"volnorm"]] UTF8String];
+                char *psz_tmp2 = (char *)[[[NSString stringWithUTF8String: psz_tmp] stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@":volnorm"]] UTF8String];
+                psz_tmp2 = (char *)[[[NSString stringWithUTF8String: psz_tmp2] stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"volnorm:"]] UTF8String];
+                psz_tmp2 = (char *)[[[NSString stringWithUTF8String: psz_tmp2] stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"volnorm"]] UTF8String];
                 config_PutPsz( p_intf, "audio-filter", psz_tmp );
+                free( psz_tmp );
             }
         }
         config_PutFloat( p_intf, "norm-max-level", [o_audio_norm_fld floatValue] );
diff --git a/modules/misc/quartztext.c b/modules/misc/quartztext.c
index b3b9244..3ac67b5 100644
--- a/modules/misc/quartztext.c
+++ b/modules/misc/quartztext.c
@@ -749,7 +749,9 @@ static offscreen_bitmap_t *Compose( int i_text_align, UniChar *psz_utf16_str, ui
             CGContextSetTextDrawingMode( p_context, kCGTextFillStroke );
             CGContextSetShadow( p_context, CGSizeMake( 0, 0 ), 5 );
             float black_components[4] = {0, 0, 0, 1};
-            CGContextSetShadowWithColor (p_context, CGSizeMake( 0, 0 ), 5, CGColorCreate( CGColorSpaceCreateWithName( kCGColorSpaceGenericRGB ), black_components ));
+            CGColorRef outlinecolor = CGColorCreate( CGColorSpaceCreateWithName( kCGColorSpaceGenericRGB ), black_components );
+            CGContextSetShadowWithColor (p_context, CGSizeMake( 0, 0 ), 5, outlinecolor);
+            CGColorRelease( outlinecolor );
             do
             {
                 // ATSUBreakLine will automatically pick up any manual '\n's also




More information about the vlc-devel mailing list