Дважды срабатывает CloseListener при програмном закрытии диалоговых окон #PL-2166 Fixed

This commit is contained in:
Konstantin Devyatkin 2013-05-27 13:47:56 +00:00
parent b9f4dd8d76
commit 39793f96fa

View File

@ -751,6 +751,7 @@ public class WebWindowManager extends WindowManager {
getCurrentWindowData().windows.clear();
for (com.vaadin.ui.Window win : new ArrayList<>(AppUI.getCurrent().getWindows())) {
removeCloseListeners(win);
AppUI.getCurrent().removeWindow(win);
Component currentView = AppUI.getCurrent().getContent();
if (currentView instanceof AppWindow)
@ -758,6 +759,13 @@ public class WebWindowManager extends WindowManager {
}
}
private void removeCloseListeners(com.vaadin.ui.Window win) {
Collection listeners = win.getListeners(com.vaadin.ui.Window.CloseEvent.class);
for (Object listener : listeners) {
win.removeCloseListener((com.vaadin.ui.Window.CloseListener) listener);
}
}
private void closeWindow(Window window, WindowOpenMode openMode) {
AppWindow appWindow = app.getAppWindow();
@ -771,6 +779,7 @@ public class WebWindowManager extends WindowManager {
switch (openMode.openType) {
case DIALOG: {
final com.vaadin.ui.Window win = (com.vaadin.ui.Window) openMode.getData();
removeCloseListeners(win);
AppUI.getCurrent().removeWindow(win);
fireListeners(window, getTabs().size() != 0);
break;