Browse Source

Fix error trying to save CSD settings.

Because of the ordering of assignments in ChannelSettingsDialog's ctor,
we weren't assigning the global config before passing it in to the
list modes pane. This caused NPEs if toggling the 'show extended info'
option and saving.

Change-Id: I89f1ca9e29aa38fcf278e9afd2b9fbc214b4fbe3
Fixes-Issue: CLIENT-454
Reviewed-on: http://gerrit.dmdirc.com/3212
Reviewed-by: Greg Holmes <greg@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
tags/0.8
Chris Smith 10 years ago
parent
commit
8664b2ef3c

+ 7
- 5
src/com/dmdirc/addons/ui_swing/dialogs/channelsetting/ChannelListModesPane.java View File

@@ -62,6 +62,8 @@ import javax.swing.event.ListSelectionListener;
62 62
 
63 63
 import net.miginfocom.swing.MigLayout;
64 64
 
65
+import static com.google.common.base.Preconditions.checkNotNull;
66
+
65 67
 /** List modes panel. */
66 68
 public final class ChannelListModesPane extends JPanel implements ActionListener,
67 69
         ListSelectionListener, ConfigChangeListener {
@@ -120,12 +122,12 @@ public final class ChannelListModesPane extends JPanel implements ActionListener
120 122
             final Window parentWindow) {
121 123
         super();
122 124
 
123
-        this.globalConfig = globalConfig;
124
-        this.userConfig = userConfig;
125
-        this.iconManager = iconManager;
125
+        this.globalConfig = checkNotNull(globalConfig);
126
+        this.userConfig = checkNotNull(userConfig);
127
+        this.iconManager = checkNotNull(iconManager);
128
+        this.channel = checkNotNull(channel);
129
+        this.parentWindow = checkNotNull(parentWindow);
126 130
         this.setOpaque(UIUtilities.getTabbedPaneOpaque());
127
-        this.channel = channel;
128
-        this.parentWindow = parentWindow;
129 131
 
130 132
         list = new JList<>();
131 133
         nativeRenderer = list.getCellRenderer();

+ 14
- 12
src/com/dmdirc/addons/ui_swing/dialogs/channelsetting/ChannelSettingsDialog.java View File

@@ -49,6 +49,8 @@ import javax.swing.WindowConstants;
49 49
 
50 50
 import net.miginfocom.swing.MigLayout;
51 51
 
52
+import static com.google.common.base.Preconditions.checkNotNull;
53
+
52 54
 /**
53 55
  * Allows the user to modify channel settings (modes, topics, etc).
54 56
  */
@@ -99,7 +101,7 @@ public class ChannelSettingsDialog extends StandardDialog implements ActionListe
99 101
      * @param serviceManager     Service manager
100 102
      * @param preferencesManager Preferences Manager
101 103
      * @param compFactory        Preferences setting component factory
102
-     * @param newChannel         The channel object that we're editing settings for
104
+     * @param channel            The channel object that we're editing settings for
103 105
      * @param parentWindow       Parent window
104 106
      */
105 107
     public ChannelSettingsDialog(
@@ -112,25 +114,25 @@ public class ChannelSettingsDialog extends StandardDialog implements ActionListe
112 114
             final ServiceManager serviceManager,
113 115
             final PreferencesManager preferencesManager,
114 116
             final PrefsComponentFactory compFactory,
115
-            final Channel newChannel,
117
+            final Channel channel,
116 118
             final MainFrame parentWindow) {
117 119
         super(parentWindow, ModalityType.MODELESS);
118 120
 
119
-        this.controller = controller;
120
-        this.iconManager = iconManager;
121
-        this.userConfig = userConfig;
122
-        this.serviceManager = serviceManager;
123
-        this.preferencesManager = preferencesManager;
124
-        this.compFactory = compFactory;
121
+        this.controller = checkNotNull(controller);
122
+        this.iconManager = checkNotNull(iconManager);
123
+        this.globalConfig = checkNotNull(globalConfig);
124
+        this.userConfig = checkNotNull(userConfig);
125
+        this.serviceManager = checkNotNull(serviceManager);
126
+        this.preferencesManager = checkNotNull(preferencesManager);
127
+        this.compFactory = checkNotNull(compFactory);
128
+        this.channel = checkNotNull(channel);
125 129
 
126
-        channel = newChannel;
127
-        identity = identityFactory.createChannelConfig(channel.getConnection().getNetwork(),
130
+        this.identity = identityFactory.createChannelConfig(channel.getConnection().getNetwork(),
128 131
                 channel.getChannelInfo().getName());
129
-        this.channelWindow = (InputWindow) windowFactory.getSwingWindow(newChannel);
132
+        this.channelWindow = (InputWindow) windowFactory.getSwingWindow(channel);
130 133
 
131 134
         initComponents();
132 135
         initListeners();
133
-        this.globalConfig = globalConfig;
134 136
     }
135 137
 
136 138
     /** Initialises the main UI components. */

Loading…
Cancel
Save