Program: 143576
Project: 143576
Buggy source:
private ServoyDivDialog createDivDialog(MainPage dialogContainer,String name){
  final ServoyDivDialog divDialog=new ServoyDivDialog(divDialogRepeater.newChildId(),true);
  divDialog.setPageMapName(null);
  divDialog.setCookieName(COOKIE_PREFIX + name);
  divDialog.setModal(true);
  dialogContainer.showingInDialog=true;
  dialogContainer.showingInWindow=false;
  divDialog.setPageCreator(new ModalWindow.PageCreator(){
    private static final long serialVersionUID=1L;
    public Page createPage(){
      return (MainPage)((FormManager)client.getFormManager()).getOrCreateMainContainer(divDialog.getPageMapName());
    }
  }
);
  divDialog.setWindowClosedCallback(new ModalWindow.WindowClosedCallback(){
    private static final long serialVersionUID=1L;
    public void onClose(    AjaxRequestTarget target){
      divDialogRepeater.remove(divDialog);
      divDialogs.remove(divDialog.getPageMapName());
      if (divDialogs.size() == 0) {
        divDialogsParent.setVisible(false);
      }
 else {
        jsActionBuffer.addAction(new DivDialogAction(divDialog,DivDialogAction.OP_DIALOG_ADDED_OR_REMOVED,new Object[]{divDialogsParent}));
      }
      divDialog.setPageMapName(null);
      restoreFocusedComponentInParentIfNeeded();
      WebEventExecutor.generateResponse(target,findPage());
    }
  }
);
  divDialog.setCloseButtonCallback(new ModalWindow.CloseButtonCallback(){
    private static final long serialVersionUID=1L;
    public boolean onCloseButtonClicked(    AjaxRequestTarget target){
      if (!divDialog.isShown()) {
        return false;
      }
      FormManager fm=((FormManager)client.getFormManager());
      IMainContainer divDialogContainer=fm.getMainContainer(divDialog.getPageMapName());
      IMainContainer currentContainer=fm.getCurrentContainer();
      if (divDialogContainer instanceof MainPage) {
        ((MainPage)divDialogContainer).touch();
      }
      fm.setCurrentContainer(divDialogContainer,divDialogContainer.getContainerName());
      if (client.getEventDispatcher() != null) {
        client.getEventDispatcher().addEvent(new Runnable(){
          public void run(){
            client.getRuntimeWindowManager().closeFormInWindow(divDialog.getPageMapName(),divDialog.getCloseAll());
          }
        }
);
      }
 else {
        client.getRuntimeWindowManager().closeFormInWindow(divDialog.getPageMapName(),divDialog.getCloseAll());
      }
      fm.setCurrentContainer(currentContainer,currentContainer.getContainerName());
      if (divDialogContainer instanceof MainPage) {
        target.addComponent(divDialog);
      }
      WebEventExecutor.generateResponse(target,divDialog.getPage());
      return false;
    }
  }
);
  divDialogRepeater.add(divDialog);
  divDialogsParent.setVisible(true);
  jsActionBuffer.addAction(new DivDialogAction(divDialog,DivDialogAction.OP_DIALOG_ADDED_OR_REMOVED,new Object[]{divDialogsParent}));
  divDialogs.put(name,divDialog);
  return divDialog;
}

Fixed version (ground truth):
private ServoyDivDialog createDivDialog(MainPage dialogContainer,String name){
  final ServoyDivDialog divDialog=new ServoyDivDialog(divDialogRepeater.newChildId(),true);
  divDialog.setPageMapName(null);
  divDialog.setCookieName(COOKIE_PREFIX + name);
  divDialog.setModal(true);
  dialogContainer.showingInDialog=true;
  dialogContainer.showingInWindow=false;
  divDialog.setPageCreator(new ModalWindow.PageCreator(){
    private static final long serialVersionUID=1L;
    public Page createPage(){
      return (MainPage)((FormManager)client.getFormManager()).getOrCreateMainContainer(divDialog.getPageMapName());
    }
  }
);
  divDialog.setWindowClosedCallback(new ModalWindow.WindowClosedCallback(){
    private static final long serialVersionUID=1L;
    public void onClose(    AjaxRequestTarget target){
      divDialogRepeater.remove(divDialog);
      String divDialogPageMapName=divDialog.getPageMapName();
      if (divDialogs.get(divDialogPageMapName) == divDialog) {
        divDialogs.remove(divDialogPageMapName);
      }
      if (divDialogs.size() == 0) {
        divDialogsParent.setVisible(false);
      }
 else {
        jsActionBuffer.addAction(new DivDialogAction(divDialog,DivDialogAction.OP_DIALOG_ADDED_OR_REMOVED,new Object[]{divDialogsParent}));
      }
      divDialog.setPageMapName(null);
      restoreFocusedComponentInParentIfNeeded();
      WebEventExecutor.generateResponse(target,findPage());
    }
  }
);
  divDialog.setCloseButtonCallback(new ModalWindow.CloseButtonCallback(){
    private static final long serialVersionUID=1L;
    public boolean onCloseButtonClicked(    AjaxRequestTarget target){
      if (!divDialog.isShown()) {
        return false;
      }
      FormManager fm=((FormManager)client.getFormManager());
      IMainContainer divDialogContainer=fm.getMainContainer(divDialog.getPageMapName());
      IMainContainer currentContainer=fm.getCurrentContainer();
      if (divDialogContainer instanceof MainPage) {
        ((MainPage)divDialogContainer).touch();
      }
      fm.setCurrentContainer(divDialogContainer,divDialogContainer.getContainerName());
      if (client.getEventDispatcher() != null) {
        client.getEventDispatcher().addEvent(new Runnable(){
          public void run(){
            client.getRuntimeWindowManager().closeFormInWindow(divDialog.getPageMapName(),divDialog.getCloseAll());
          }
        }
);
      }
 else {
        client.getRuntimeWindowManager().closeFormInWindow(divDialog.getPageMapName(),divDialog.getCloseAll());
      }
      fm.setCurrentContainer(currentContainer,currentContainer.getContainerName());
      if (divDialogContainer instanceof MainPage) {
        target.addComponent(divDialog);
      }
      WebEventExecutor.generateResponse(target,divDialog.getPage());
      return false;
    }
  }
);
  divDialogRepeater.add(divDialog);
  divDialogsParent.setVisible(true);
  jsActionBuffer.addAction(new DivDialogAction(divDialog,DivDialogAction.OP_DIALOG_ADDED_OR_REMOVED,new Object[]{divDialogsParent}));
  divDialogs.put(name,divDialog);
  return divDialog;
}