Ticket #17401: 17401-v4-poc.patch

File 17401-v4-poc.patch, 3.3 KB (added by GerdP, 7 years ago)

different approach: disable command stack window updates while fixing errors

  • src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java

     
    8989    private final SelectAction selectAction = new SelectAction();
    9090    private final SelectAndZoomAction selectAndZoomAction = new SelectAndZoomAction();
    9191
     92    private boolean notInSync;
     93    private boolean passive;
     94
    9295    /**
    9396     * Constructs a new {@code CommandStackDialog}.
    9497     */
     
    375378    @Override
    376379    public void commandAdded(CommandAddedEvent e) {
    377380        if (isVisible()) {
    378             undoRoot.add(getNodeForCommand(e.getCommand()));
    379             undoTreeModel.nodeStructureChanged(undoRoot);
    380             // fix 16911: make sure that redo tree is rebuild with empty list
    381             if (!redoTreeIsEmpty())
    382                 buildRedoTree();
    383             ensureTreesConsistency();
     381            if (passive) {
     382                notInSync = true;
     383            } else {
     384                undoRoot.add(getNodeForCommand(e.getCommand()));
     385                undoTreeModel.nodeStructureChanged(undoRoot);
     386                // fix 16911: make sure that redo tree is rebuild with empty list
     387                if (!redoTreeIsEmpty())
     388                    buildRedoTree();
     389                ensureTreesConsistency();
     390            }
    384391        }
    385392    }
    386393
     
    550557            add(selectAndZoomAction);
    551558        }
    552559    }
     560
     561    /**
     562     * Allows to set the dialog into passive mode so that updates to the undo/redo tree are ignored
     563     * @param b true: enable passive mode, false: disable passive mode and rebuild dialog
     564     */
     565    public void setPassive(boolean b) {
     566        if (passive) {
     567            if (!b) {
     568                passive = false;
     569                if (notInSync) {
     570                    buildTrees();
     571                    notInSync = false;
     572                }
     573            }
     574        } else {
     575            passive = b;
     576        }
     577    }
    553578}
  • src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java

     
    618618        @Override
    619619        protected void realRun() throws SAXException, IOException, OsmTransferException {
    620620            ProgressMonitor monitor = getProgressMonitor();
     621            CommandStackDialog cmdStackPanel = dialogsPanel.getToggleDialog(CommandStackDialog.class);
    621622            try {
     623                if (cmdStackPanel != null && testErrors.size() > 100) {
     624                    cmdStackPanel.setPassive(true);
     625                }
    622626                monitor.setTicksCount(testErrors.size());
    623627                final DataSet ds = MainApplication.getLayerManager().getActiveDataSet();
    624628                int i = 0;
     
    646650                throw new JosmRuntimeException(e);
    647651            } finally {
    648652                monitor.finishTask();
     653                if (cmdStackPanel != null) {
     654                    cmdStackPanel.setPassive(false);
     655                }
    649656            }
    650657        }
    651658    }