[vlc-commits] macosx: Simplify usage of toNSStr and _NS

David Fuhrmann git at videolan.org
Sun Jun 10 11:03:01 CEST 2018


vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Sat Jun  9 19:37:41 2018 +0200| [f31ea49802cd81a1104bb9ea60be46adaddf18e7] | committer: David Fuhrmann

macosx: Simplify usage of toNSStr and _NS

Both correctly check for NULL char* already.

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

 modules/gui/macosx/prefs_widgets.m | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/modules/gui/macosx/prefs_widgets.m b/modules/gui/macosx/prefs_widgets.m
index 32f1912af8..4eb5a2983c 100644
--- a/modules/gui/macosx/prefs_widgets.m
+++ b/modules/gui/macosx/prefs_widgets.m
@@ -935,10 +935,7 @@ o_textfield = [[NSSecureTextField alloc] initWithFrame: s_rc];              \
         [self addSubview: self.label];
 
         /* build the textfield */
-        if (p_item->value.psz)
-            o_textfieldString = toNSStr(p_item->value.psz);
-        else
-            o_textfieldString = @"";
+        o_textfieldString = toNSStr(p_item->value.psz);
         if (p_item->i_type == CONFIG_ITEM_PASSWORD) {
             ADD_SECURETEXTFIELD(o_textfield, mainFrame, [self.label frame].size.width + 2,
                                 0, mainFrame.size.width - [self.label frame].size.width -
@@ -1126,10 +1123,7 @@ o_textfield = [[NSSecureTextField alloc] initWithFrame: s_rc];              \
         [self addSubview: o_button];
 
         /* build the textfield */
-        if (p_item->value.psz)
-            o_textfieldString = [NSString stringWithFormat: @"%s", (char *)p_item->value.psz];
-        else
-            o_textfieldString = @"";
+        o_textfieldString = toNSStr(p_item->value.psz);
         ADD_TEXTFIELD(o_textfield, mainFrame, 12, 2, mainFrame.size.width -
                       8 - [o_button frame].size.width,
                       o_itemTooltip, o_textfieldString)
@@ -2099,10 +2093,7 @@ o_moduleenabled = [NSNumber numberWithBool:NO];\
     [self addSubview: self.label];
 
     /* build the textfield */
-    if (p_item->value.psz)
-        o_textfieldString = _NS(p_item->value.psz);
-    else
-        o_textfieldString = @"";
+    o_textfieldString = _NS(p_item->value.psz);
     ADD_TEXTFIELD(o_textfield, mainFrame, [self.label frame].size.width + 2,
                   mainFrame.size.height - 22, mainFrame.size.width -
                   [self.label frame].size.width - 2, toolTip, o_textfieldString)



More information about the vlc-commits mailing list