Changeset 16554 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2020-06-07T15:04:13+02:00 (4 years ago)
Author:
GerdP
Message:

fix #19355: NPE at org.openstreetmap.josm.gui.dialogs.relation.ReferringRelationsBrowserModel.canReload()

  • don't use relation created by createMultipolygonCommand as it was not yet added to the dataset
  • get the correct relation after command was executed

(maybe RelationEditor.getEditor() is the better place to do this, adding a null check in canReload() makes no sense as other methods also cannot handle a relation without dataset)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java

    r16438 r16554  
    112112            }
    113113            final Command command = commandAndRelation.a;
    114             final Relation relation = commandAndRelation.b;
    115114
    116115            // to avoid EDT violations
    117116            SwingUtilities.invokeLater(() -> {
    118117                    UndoRedoHandler.getInstance().add(command);
    119 
    120                     // Use 'SwingUtilities.invokeLater' to make sure the relationListDialog
    121                     // knows about the new relation before we try to select it.
    122                     // (Yes, we are already in event dispatch thread. But DatasetEventManager
    123                     // uses 'SwingUtilities.invokeLater' to fire events so we have to do the same.)
    124                     SwingUtilities.invokeLater(() -> {
    125                             MainApplication.getMap().relationListDialog.selectRelation(relation);
    126                             if (Config.getPref().getBoolean("multipoly.show-relation-editor", false)) {
    127                                 //Open relation edit window, if set up in preferences
    128                                 RelationEditor editor = RelationEditor.getEditor(
    129                                         MainApplication.getLayerManager().getEditLayer(), relation, null);
    130                                 editor.setModal(true);
    131                                 editor.setVisible(true);
    132                             } else {
    133                                 MainApplication.getLayerManager().getEditLayer().setRecentRelation(relation);
    134                             }
    135                     });
     118                final Relation relation = (Relation) MainApplication.getLayerManager().getEditDataSet()
     119                        .getPrimitiveById(commandAndRelation.b);
     120
     121                // Use 'SwingUtilities.invokeLater' to make sure the relationListDialog
     122                // knows about the new relation before we try to select it.
     123                // (Yes, we are already in event dispatch thread. But DatasetEventManager
     124                // uses 'SwingUtilities.invokeLater' to fire events so we have to do the same.)
     125                SwingUtilities.invokeLater(() -> {
     126                    MainApplication.getMap().relationListDialog.selectRelation(relation);
     127                    if (Config.getPref().getBoolean("multipoly.show-relation-editor", false)) {
     128                        //Open relation edit window, if set up in preferences
     129                        RelationEditor editor = RelationEditor
     130                                .getEditor(MainApplication.getLayerManager().getEditLayer(), relation, null);
     131                        editor.setModal(true);
     132                        editor.setVisible(true);
     133                    } else {
     134                        MainApplication.getLayerManager().getEditLayer().setRecentRelation(relation);
     135                    }
     136                });
    136137            });
    137138        }
Note: See TracChangeset for help on using the changeset viewer.