Ignore:
Timestamp:
2021-11-28T09:05:10+01:00 (2 years ago)
Author:
GerdP
Message:

fix #21589: Reverter plugin exception: IllegalArgumentException

  • detect conflicts created by download of missing members and stop revert with notification

Not really a fix, more a "Give up, don't know how to continue". Maybe we should simply not allow reverts in layers which already contain data.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/reverter/src/reverter/RevertChangesetTask.java

    r35688 r35869  
    9898                newLayer = false; // reuse layer for subsequent reverts
    9999            } catch (OsmTransferException e) {
    100                 rollback(allcmds);
     100                rollback(allcmds);
    101101                Logging.error(e);
    102102                throw e;
    103103            } catch (UserCancelException e) {
    104                 rollback(allcmds);
     104                rollback(allcmds);
    105105                GuiHelper.executeByMainWorkerInEDT(() -> new Notification(tr("Revert was canceled")).show());
    106106                Logging.trace(e);
     
    140140        if (progressMonitor.isCanceled())
    141141            throw new UserCancelException();
    142 
     142        int numOldConflicts = oldDataSet == null ? 0 : oldDataSet.getConflicts().size();
    143143        // Check missing objects
    144144        rev.checkMissingCreated();
     
    154154            rev.downloadMissingPrimitives(progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false));
    155155        }
     156        int numConflicts = oldDataSet == null ? 0 : oldDataSet.getConflicts().size();
     157        if (numConflicts > numOldConflicts) {
     158            GuiHelper.runInEDT(() -> new Notification(tr("Please solve conflicts and maybe try again to revert."))
     159            .setIcon(JOptionPane.ERROR_MESSAGE)
     160            .show());
     161            return null;
     162        }
    156163
    157164        if (progressMonitor.isCanceled())
     
    173180        }
    174181        GuiHelper.runInEDT(() -> {
    175                 for (Command c : cmds) {
    176                         if (c instanceof ConflictAddCommand) {
    177                                 numberOfConflicts++;
    178                         }
    179                         c.executeCommand();
    180                 }
     182            for (Command c : cmds) {
     183                if (c instanceof ConflictAddCommand) {
     184                    numberOfConflicts++;
     185                }
     186                c.executeCommand();
     187            }
    181188        });
    182189        final String desc;
     
    189196    }
    190197
    191         @Override
    192         protected void cancel() {
     198    @Override
     199    protected void cancel() {
    193200        // nothing to do
    194         }
    195 
    196         @Override
    197         protected void finish() {
     201    }
     202
     203    @Override
     204    protected void finish() {
    198205        // nothing to do
    199206
    200         }
     207    }
    201208
    202209    /**
Note: See TracChangeset for help on using the changeset viewer.