Changeset 5673 in josm for trunk


Ignore:
Timestamp:
2013-01-26T18:24:57+01:00 (11 years ago)
Author:
Don-vip
Message:

fix #4304 - Improve error fixing performance by calling DataSet.beginUpdate/endUpdate

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java

    r5671 r5673  
    572572            // do nothing
    573573        }
     574       
     575        protected void fixError(TestError error) throws InterruptedException, InvocationTargetException {
     576            if (error.isFixable()) {
     577                final Command fixCommand = error.getFix();
     578                if (fixCommand != null) {
     579                    SwingUtilities.invokeAndWait(new Runnable() {
     580                        @Override
     581                        public void run() {
     582                            Main.main.undoRedo.addNoRedraw(fixCommand);
     583                        }
     584                    });
     585                }
     586                // It is wanted to ignore an error if it said fixable, even if fixCommand was null
     587                // This is to fix #5764 and #5773: a delete command, for example, may be null if all concerned primitives have already been deleted
     588                error.setIgnored(true);
     589            }
     590        }
    574591
    575592        @Override
     
    580597                monitor.setTicksCount(testErrors.size());
    581598                int i=0;
    582                 for (TestError error: testErrors) {
    583                     i++;
    584                     monitor.subTask(tr("Fixing ({0}/{1}): ''{2}''", i, testErrors.size(),error.getMessage()));
    585                     if (this.canceled)
    586                         return;
    587                     if (error.isFixable()) {
    588                         final Command fixCommand = error.getFix();
    589                         if (fixCommand != null) {
    590                             SwingUtilities.invokeAndWait(new Runnable() {
    591                                 @Override
    592                                 public void run() {
    593                                     Main.main.undoRedo.addNoRedraw(fixCommand);
    594                                 }
    595                             });
     599                SwingUtilities.invokeAndWait(new Runnable() {
     600                    @Override
     601                    public void run() {
     602                        Main.main.getCurrentDataSet().beginUpdate();
     603                    }
     604                });
     605                try {
     606                    for (TestError error: testErrors) {
     607                        i++;
     608                        monitor.subTask(tr("Fixing ({0}/{1}): ''{2}''", i, testErrors.size(),error.getMessage()));
     609                        if (this.canceled)
     610                            return;
     611                        fixError(error);
     612                        monitor.worked(1);
     613                    }
     614                } finally {
     615                    SwingUtilities.invokeAndWait(new Runnable() {
     616                        @Override
     617                        public void run() {
     618                            Main.main.getCurrentDataSet().endUpdate();
    596619                        }
    597                         // It is wanted to ignore an error if it said fixable, even if fixCommand was null
    598                         // This is to fix #5764 and #5773: a delete command, for example, may be null if all concerned primitives have already been deleted
    599                         error.setIgnored(true);
    600                     }
    601                     monitor.worked(1);
     620                    });
    602621                }
    603622                monitor.subTask(tr("Updating map ..."));
Note: See TracChangeset for help on using the changeset viewer.