소스 검색

Merge pull request #698 from csmith/master

Avoid raising events before a frame has an ID.
pull/700/head
Greg Holmes 8 년 전
부모
커밋
b20d26e844
3개의 변경된 파일28개의 추가작업 그리고 6개의 파일을 삭제
  1. 0
    1
      src/main/java/com/dmdirc/Channel.java
  2. 1
    0
      src/main/java/com/dmdirc/ChannelFactory.java
  3. 27
    5
      src/main/java/com/dmdirc/FrameContainer.java

+ 0
- 1
src/main/java/com/dmdirc/Channel.java 파일 보기

120
         initBackBuffer();
120
         initBackBuffer();
121
         registerCallbacks();
121
         registerCallbacks();
122
         updateTitle();
122
         updateTitle();
123
-        selfJoin();
124
     }
123
     }
125
 
124
 
126
     public ChannelInfo getChannelInfo() {
125
     public ChannelInfo getChannelInfo() {

+ 1
- 0
src/main/java/com/dmdirc/ChannelFactory.java 파일 보기

82
                 channel::getMaxLineLength));
82
                 channel::getMaxLineLength));
83
         windowManager.addWindow(connection.getWindowModel(), channel);
83
         windowManager.addWindow(connection.getWindowModel(), channel);
84
         connection.getWindowModel().getEventBus().publish(new ChannelOpenedEvent(channel));
84
         connection.getWindowModel().getEventBus().publish(new ChannelOpenedEvent(channel));
85
+        channel.selfJoin();
85
         return channel;
86
         return channel;
86
     }
87
     }
87
 }
88
 }

+ 27
- 5
src/main/java/com/dmdirc/FrameContainer.java 파일 보기

125
         this.id = id;
125
         this.id = id;
126
     }
126
     }
127
 
127
 
128
+    /**
129
+     * Indicates whether this container has been assigned an ID yet.
130
+     *
131
+     * <p>The container should not post events until it has an ID.
132
+     *
133
+     * @return True if the container has an ID, false otherwise.
134
+     */
135
+    protected boolean hasId() {
136
+        return id != null;
137
+    }
138
+
128
     @Override
139
     @Override
129
     public String getIcon() {
140
     public String getIcon() {
130
         return icon;
141
         return icon;
154
     public void setName(final String name) {
165
     public void setName(final String name) {
155
         this.name = name;
166
         this.name = name;
156
 
167
 
157
-        eventBus.publishAsync(new FrameNameChangedEvent(this, name));
168
+        if (hasId()) {
169
+            eventBus.publishAsync(new FrameNameChangedEvent(this, name));
170
+        }
158
     }
171
     }
159
 
172
 
160
     @Override
173
     @Override
161
     public void setTitle(final String title) {
174
     public void setTitle(final String title) {
162
         this.title = title;
175
         this.title = title;
163
 
176
 
164
-        eventBus.publishAsync(new FrameTitleChangedEvent(this, title));
177
+        if (hasId()) {
178
+            eventBus.publishAsync(new FrameTitleChangedEvent(this, title));
179
+        }
165
     }
180
     }
166
 
181
 
167
     @Override
182
     @Override
172
     @Override
187
     @Override
173
     public void addComponent(final String component) {
188
     public void addComponent(final String component) {
174
         components.add(component);
189
         components.add(component);
175
-        eventBus.publishAsync(new FrameComponentAddedEvent(this, component));
190
+
191
+        if (hasId()) {
192
+            eventBus.publishAsync(new FrameComponentAddedEvent(this, component));
193
+        }
176
     }
194
     }
177
 
195
 
178
     @Override
196
     @Override
179
     public void removeComponent(final String component) {
197
     public void removeComponent(final String component) {
180
         components.remove(component);
198
         components.remove(component);
181
 
199
 
182
-        eventBus.publishAsync(new FrameComponentRemovedEvent(this, component));
200
+        if (hasId()) {
201
+            eventBus.publishAsync(new FrameComponentRemovedEvent(this, component));
202
+        }
183
     }
203
     }
184
 
204
 
185
     @Override
205
     @Override
204
      * Called when this container's icon is updated.
224
      * Called when this container's icon is updated.
205
      */
225
      */
206
     private void iconUpdated() {
226
     private void iconUpdated() {
207
-        eventBus.publish(new FrameIconChangedEvent(this, icon));
227
+        if (hasId()) {
228
+            eventBus.publish(new FrameIconChangedEvent(this, icon));
229
+        }
208
     }
230
     }
209
 
231
 
210
     @Override
232
     @Override

Loading…
취소
저장