Ignore:
Timestamp:
2012-08-24T13:41:33+02:00 (12 years ago)
Author:
donvip
Message:

[josm_plugins] See #josm7980 - Fix memory leaks in alignways, fixAdresses, measurement, routing, turnlanes and waypoint_search plugins

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/waypoint_search/src/org/openstreetmap/josm/plugins/waypointSearch/WaypointSearchPlugin.java

    r23192 r28624  
    11package org.openstreetmap.josm.plugins.waypointSearch;
    22
     3import static org.openstreetmap.josm.tools.I18n.tr;
     4
     5import org.openstreetmap.josm.gui.MapFrame;
     6import org.openstreetmap.josm.gui.MapView;
     7import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
     8import org.openstreetmap.josm.gui.layer.Layer;
    39import org.openstreetmap.josm.plugins.Plugin;
    410import org.openstreetmap.josm.plugins.PluginInformation;
    5 import org.openstreetmap.josm.Main;
    6 import org.openstreetmap.josm.gui.MapView;
    7 import org.openstreetmap.josm.gui.layer.Layer;
    8 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
    9 import static org.openstreetmap.josm.tools.I18n.tr;
    1011
    1112public class WaypointSearchPlugin extends Plugin implements LayerChangeListener  {
     
    1516    * @param info  information about the plugin and its local installation   
    1617    */
    17     private Engine engine = new Engine();
    18     private SelectWaypointDialog waypointDialog = new SelectWaypointDialog(tr("Waypoint search"), "ToolbarIcon", tr("Search after waypoint. Click and move the map view to the waypoint."), null, 100);
     18    private final Engine engine = new Engine();
     19    private SelectWaypointDialog waypointDialog;
    1920   
    2021    public WaypointSearchPlugin(PluginInformation info) {
     
    2324    }
    2425     
    25     @Override
     26        @Override
     27        public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
     28                if (newFrame != null) {
     29                        newFrame.addToggleDialog(waypointDialog = new SelectWaypointDialog(
     30                                        tr("Waypoint search"), "ToolbarIcon", tr("Search after waypoint. Click and move the map view to the waypoint."), null, 100));
     31                } else {
     32                        waypointDialog = null;
     33                }
     34        }
     35
     36        @Override
    2637    public void activeLayerChange(Layer oldLayer, Layer newLayer) {
    27         // TODO Auto-generated method stub
    28        
    2938    }
    30 
    3139   
    3240    @Override
    3341    public void layerAdded(Layer newLayer) {
    34         //add dialog
    35         if (Main.map.getToggleDialog(SelectWaypointDialog.class)==null) {
    36             Main.map.addToggleDialog(waypointDialog);
    37         }
    38         //update search
    39         if (engine.gpxLayersExist()) {
     42        // update search
     43        if (waypointDialog != null && engine.gpxLayersExist()) {
    4044            waypointDialog.updateSearchResults();
    4145        }
    4246    }
    4347
    44 
    45 
    4648    @Override
    4749    public void layerRemoved(Layer oldLayer) {
    48         if (!engine.gpxLayersExist()) {
     50        if (waypointDialog != null && !engine.gpxLayersExist()) {
    4951            waypointDialog.updateSearchResults();
    5052        }   
    5153    }
    52  
    5354}
    54 
    55 
    56 
    57    
    58    
    59    
    60 
    61 
    62 
    63 
    64 
    65 
    66 
    67 
    68 
    69 
    70 
    71 
    72 
    73 
    74 
    75 
    76 
    77    
    78    
    79 
    80 
    81 
    82 
    83 
    84 
Note: See TracChangeset for help on using the changeset viewer.