Changeset 5984 in josm for trunk


Ignore:
Timestamp:
2013-06-02T00:07:54+02:00 (7 years ago)
Author:
Don-vip
Message:

fix #7700 - fix all EDT violations observed while merging layers, most likely causing the internal Swing ClassCastException

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

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

    r5526 r5984  
    1818import org.openstreetmap.josm.gui.layer.Layer;
    1919import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     20import org.openstreetmap.josm.gui.util.GuiHelper;
    2021import org.openstreetmap.josm.tools.Destroyable;
    2122import org.openstreetmap.josm.tools.ImageProvider;
     
    223224     */
    224225    private class LayerChangeAdapter implements MapView.LayerChangeListener {
     226        private void updateEnabledStateInEDT() {
     227            GuiHelper.runInEDT(new Runnable() {
     228                @Override public void run() {
     229                    updateEnabledState();
     230                }
     231            });
     232        }
    225233        public void activeLayerChange(Layer oldLayer, Layer newLayer) {
    226             updateEnabledState();
     234            updateEnabledStateInEDT();
    227235        }
    228236
    229237        public void layerAdded(Layer newLayer) {
    230             updateEnabledState();
     238            updateEnabledStateInEDT();
    231239        }
    232240
    233241        public void layerRemoved(Layer oldLayer) {
    234             updateEnabledState();
     242            updateEnabledStateInEDT();
    235243        }
    236244    }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java

    r5958 r5984  
    6666import org.openstreetmap.josm.gui.SideButton;
    6767import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     68import org.openstreetmap.josm.gui.util.GuiHelper;
    6869import org.openstreetmap.josm.gui.widgets.ListPopupMenu;
    6970import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
     
    128129    }
    129130
     131    /**
     132     * Constructs a new {@code SelectionListDialog}.
     133     */
    130134    public SelectionListDialog() {
    131135        super(tr("Selection"), "selectionlist", tr("Open a selection list window."),
     
    219223    }
    220224
     225    /**
     226     * Replies the selected OSM primitives.
     227     * @return The selected OSM primitives
     228     */
    221229    public Collection<OsmPrimitive> getSelectedPrimitives() {
    222230        return model.getSelected();
     
    484492
    485493        /**
    486          * Replies the collection of OSM primitives in the view
    487          * of this model
    488          *
    489          * @return complete content of the view
    490          */
    491         public Collection<OsmPrimitive> getAllElements() {
    492             return selection;
    493         }
    494 
    495         /**
    496494         * Sets the OSM primitives to be selected in the view of this model
    497495         *
     
    521519         * @param selection the collection of currently selected OSM objects
    522520         */
    523         public void setJOSMSelection(Collection<? extends OsmPrimitive> selection) {
     521        public void setJOSMSelection(final Collection<? extends OsmPrimitive> selection) {
    524522            this.selection.clear();
    525             if (selection == null) {
    526                 fireContentsChanged(this, 0, getSize());
    527                 return;
    528             }
    529             this.selection.addAll(selection);
    530             sort();
    531             fireContentsChanged(this, 0, getSize());
    532             remember(selection);
    533             double dist = -1;
    534             SubclassFilteredCollection<OsmPrimitive, Way> ways = new SubclassFilteredCollection<OsmPrimitive, Way>(selection, OsmPrimitive.wayPredicate);
    535             // Compute total length of selected way(s) until an arbitrary limit set to 250 ways
    536             // in order to prevent performance issue if a large number of ways are selected (old behaviour kept in that case, see #8403)
    537             int maxWays = Math.max(1, Main.pref.getInteger("selection.max-ways-for-statusline", 250));
    538             if (!ways.isEmpty() && ways.size() <= maxWays) {
    539                 dist = 0.0;
    540                 for (Way w : ways) {
    541                     dist += w.getLength();
     523            if (selection != null) {
     524                this.selection.addAll(selection);
     525                sort();
     526            }
     527            GuiHelper.runInEDTAndWait(new Runnable() {
     528                @Override public void run() {
     529                    fireContentsChanged(this, 0, getSize());
     530                    if (selection != null) {
     531                        remember(selection);
     532                        double dist = -1;
     533                        SubclassFilteredCollection<OsmPrimitive, Way> ways = new SubclassFilteredCollection<OsmPrimitive, Way>(selection, OsmPrimitive.wayPredicate);
     534                        // Compute total length of selected way(s) until an arbitrary limit set to 250 ways
     535                        // in order to prevent performance issue if a large number of ways are selected (old behaviour kept in that case, see #8403)
     536                        int maxWays = Math.max(1, Main.pref.getInteger("selection.max-ways-for-statusline", 250));
     537                        if (!ways.isEmpty() && ways.size() <= maxWays) {
     538                            dist = 0.0;
     539                            for (Way w : ways) {
     540                                dist += w.getLength();
     541                            }
     542                        }
     543                        Main.map.statusLine.setDist(dist);
     544                    }
    542545                }
    543             }
    544             Main.map.statusLine.setDist(dist);
     546            });
    545547        }
    546548
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r5975 r5984  
    8585import org.openstreetmap.josm.gui.tagging.TaggingPreset;
    8686import org.openstreetmap.josm.gui.tagging.TaggingPreset.PresetType;
     87import org.openstreetmap.josm.gui.util.GuiHelper;
    8788import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
    8889import org.openstreetmap.josm.tools.GBC;
     
    683684        if (newLayer == null) editHelper.saveTagsIfNeeded();
    684685        // it is time to save history of tags
    685            
    686         updateSelection();
     686        GuiHelper.runInEDT(new Runnable() {
     687            @Override public void run() {
     688                updateSelection();
     689            }
     690        });
    687691    }
    688692
Note: See TracChangeset for help on using the changeset viewer.