Pārlūkot izejas kodu

Fix NPE if removing non-existant listener type

Fixes issue 4039

Change-Id: Ie5ff2edc27c062cf6ff671a8cc88bcd2c80da075
Reviewed-on: http://gerrit.dmdirc.com/1184
Automatic-Compile: DMDirc Local Commits <dmdirc@googlemail.com>
Reviewed-by: Gregory Holmes <greg@dmdirc.com>
tags/0.6.4
Chris Smith 14 gadus atpakaļ
vecāks
revīzija
0d83d4fe23
1 mainītis faili ar 7 papildinājumiem un 4 dzēšanām
  1. 7
    4
      src/com/dmdirc/util/ListenerList.java

+ 7
- 4
src/com/dmdirc/util/ListenerList.java Parādīt failu

@@ -49,6 +49,7 @@ public class ListenerList {
49 49
     /**
50 50
      * Adds a new listener of the specified type to this listener list.
51 51
      * 
52
+     * @param <T> The type of listener to be added
52 53
      * @param listenerType The type of listener to be added
53 54
      * @param listener The listener to be added
54 55
      */
@@ -77,12 +78,13 @@ public class ListenerList {
77 78
     /**
78 79
      * Removes the specified listener from the list of listeners for the
79 80
      * specified type.
80
-     * 
81
+     *
82
+     * @param <T> The type of listener to be removed
81 83
      * @param listenerType The type that the listener should be removed from
82 84
      * @param listener The listener to be removed
83 85
      */
84 86
     public <T> void remove(final Class<T> listenerType, final T listener) {
85
-        listeners.get(listenerType).remove(listener);
87
+        get(listenerType).remove(listener);
86 88
     }
87 89
     
88 90
     /**
@@ -94,12 +96,13 @@ public class ListenerList {
94 96
      * @param listener The listener to be removed
95 97
      */
96 98
     public void remove(final String listenerType, final Object listener) {
97
-        listeners.get(listenerType).remove(listener);
99
+        get(listenerType).remove(listener);
98 100
     }
99 101
     
100 102
     /**
101 103
      * Retrieves the list of listeners for the specified type.
102
-     * 
104
+     *
105
+     * @param <T> The type of listener to be retrieved
103 106
      * @param listenerType The type of listener that's being retrieved
104 107
      * @return A list of listeners for the specified type
105 108
      */

Notiek ielāde…
Atcelt
Saglabāt