[vlc-commits] macosx/prefswidget: fix initialization

Felix Paul Kühne git at videolan.org
Sun Jun 10 10:35:45 CEST 2018


vlc/vlc-3.0 | branch: master | Felix Paul Kühne <felix at feepk.net> | Sat Jun  9 18:21:35 2018 +0200| [4ae9cc8a7484346adf1a0c3149c8c0a1fc70cce7] | committer: Felix Paul Kühne

macosx/prefswidget: fix initialization

(cherry picked from commit 2378131a7c3351efe68f4a2cbeb582ad3a5c7815)

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

 modules/gui/macosx/prefs_widgets.m | 56 ++++++++++++++++++++++----------------
 1 file changed, 32 insertions(+), 24 deletions(-)

diff --git a/modules/gui/macosx/prefs_widgets.m b/modules/gui/macosx/prefs_widgets.m
index 409b5e3bef..431e93c78f 100644
--- a/modules/gui/macosx/prefs_widgets.m
+++ b/modules/gui/macosx/prefs_widgets.m
@@ -406,9 +406,13 @@ o_textfield = [[NSSecureTextField alloc] initWithFrame: s_rc];              \
 
     if (self != nil) {
         _p_item = p_item;
-        psz_name = p_item->psz_name;
-        _type = p_item->i_type;
-        _advanced = p_item->b_advanced;
+        if (p_item) {
+            psz_name = p_item->psz_name;
+            _type = p_item->i_type;
+            _advanced = p_item->b_advanced;
+        } else {
+            psz_name = NULL;
+        }
         [self setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin ];
     }
     return (self);
@@ -1942,6 +1946,12 @@ o_textfield = [[NSSecureTextField alloc] initWithFrame: s_rc];              \
 - (id)initWithItem:(module_config_t *)p_item
           withView:(NSView *)parentView
 {
+    self = [super initWithFrame:CGRectZero item:p_item];
+    if (!self) {
+        return self;
+    }
+    self.viewType = CONFIG_ITEM_MODULE_LIST;
+
     BOOL b_by_cat = p_item->i_type == CONFIG_ITEM_MODULE_LIST_CAT;
 
     //Fill our array to know how may items we have...
@@ -2013,7 +2023,6 @@ o_moduleenabled = [NSNumber numberWithBool:NO];\
             }
             module_config_free(p_configlist);
 
-
         } else if (module_provides(p_parser, p_item->psz_type)) {
 
             NSString *o_modulelongname = toNSStr(module_get_name(p_parser, TRUE));
@@ -2082,30 +2091,29 @@ o_moduleenabled = [NSNumber numberWithBool:NO];\
     mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
     mainFrame.origin.x = LEFTMARGIN;
     mainFrame.origin.y = 0;
-    if (self = [super initWithFrame:mainFrame item:p_item]) {
-        self.viewType = CONFIG_ITEM_MODULE_LIST;
+    self.frame = mainFrame;
 
-        toolTip = [[VLCStringUtility sharedInstance] wrapString: _NS(p_item->psz_longtext) toWidth: PREFS_WRAP];
+    toolTip = [[VLCStringUtility sharedInstance] wrapString: _NS(p_item->psz_longtext) toWidth: PREFS_WRAP];
 
-        /* add the label */
-        labelString = _NS((char *)p_item->psz_text);
-        ADD_LABEL(self.label, mainFrame, 0, -3, labelString, toolTip)
-        [self.label setAutoresizingMask:NSViewNotSizable ];
-        [self addSubview: self.label];
+    /* add the label */
+    labelString = _NS((char *)p_item->psz_text);
+    ADD_LABEL(self.label, mainFrame, 0, -3, labelString, toolTip)
+    [self.label setAutoresizingMask:NSViewNotSizable ];
+    [self addSubview: self.label];
 
-        /* build the textfield */
-        if (p_item->value.psz)
-            o_textfieldString = _NS(p_item->value.psz);
-        else
-            o_textfieldString = @"";
-        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)
-        [o_textfield setAutoresizingMask:NSViewWidthSizable ];
-        [self addSubview: o_textfield];
+    /* build the textfield */
+    if (p_item->value.psz)
+        o_textfieldString = _NS(p_item->value.psz);
+    else
+        o_textfieldString = @"";
+    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)
+    [o_textfield setAutoresizingMask:NSViewWidthSizable ];
+    [self addSubview: o_textfield];
+
+    [self addSubview: o_tableview];
 
-        [self addSubview: o_tableview];
-    }
     return self;
 }
 



More information about the vlc-commits mailing list