Ticket #18277: 18277.patch
File 18277.patch, 4.2 KB (added by , 5 years ago) |
---|
-
src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java
22 22 import java.util.List; 23 23 import java.util.Set; 24 24 import java.util.regex.Pattern; 25 import java.util.stream.Collectors; 25 26 26 27 import javax.swing.AbstractAction; 27 28 import javax.swing.BorderFactory; … … 55 56 import org.openstreetmap.josm.gui.util.GuiHelper; 56 57 import org.openstreetmap.josm.gui.widgets.FilterField; 57 58 import org.openstreetmap.josm.plugins.PluginDownloadTask; 59 import org.openstreetmap.josm.plugins.PluginHandler; 58 60 import org.openstreetmap.josm.plugins.PluginInformation; 59 61 import org.openstreetmap.josm.plugins.ReadLocalPluginInformationTask; 60 62 import org.openstreetmap.josm.plugins.ReadRemotePluginInformationTask; 61 63 import org.openstreetmap.josm.spi.preferences.Config; 64 import org.openstreetmap.josm.tools.Destroyable; 62 65 import org.openstreetmap.josm.tools.GBC; 63 66 import org.openstreetmap.josm.tools.ImageProvider; 64 67 import org.openstreetmap.josm.tools.Logging; … … 324 327 List<String> l = new LinkedList<>(model.getSelectedPluginNames()); 325 328 Collections.sort(l); 326 329 Config.getPref().putList("plugins", l); 327 if (!model.getNewlyDeactivatedPlugins().isEmpty()) 330 List<PluginInformation> deactivatedPlugins = model.getNewlyDeactivatedPlugins(); 331 if (!deactivatedPlugins.isEmpty()) { 332 List<Destroyable> noRestart = deactivatedPlugins.parallelStream() 333 .map(info -> PluginHandler.getPlugin(info.name)).filter(Destroyable.class::isInstance) 334 .map(Destroyable.class::cast).collect(Collectors.toList()); 335 noRestart.forEach(Destroyable::destroy); 336 // return true under the assumption that things will work better, even if 337 // everything was "Destroyable" 328 338 return true; 339 } 329 340 for (PluginInformation pi : model.getNewlyActivatedPlugins()) { 330 341 if (!pi.canloadatruntime) 331 342 return true; -
src/org/openstreetmap/josm/plugins/PluginHandler.java
68 68 import org.openstreetmap.josm.io.OfflineAccessException; 69 69 import org.openstreetmap.josm.io.OnlineResource; 70 70 import org.openstreetmap.josm.spi.preferences.Config; 71 import org.openstreetmap.josm.tools.Destroyable; 71 72 import org.openstreetmap.josm.tools.GBC; 72 73 import org.openstreetmap.josm.tools.I18n; 73 74 import org.openstreetmap.josm.tools.ImageProvider; … … 1167 1168 pluginsToDownload, 1168 1169 tr("Update plugins") 1169 1170 ); 1170 1171 1171 try { 1172 1172 pluginDownloadTask.run(); 1173 1173 } catch (RuntimeException e) { // NOPMD … … 1331 1331 URL oldPluginURL = updatedPlugin.toURI().toURL(); 1332 1332 pluginsToLoad.stream().filter(x -> x.libraries.contains(oldPluginURL)).forEach( 1333 1333 x -> Collections.replaceAll(x.libraries, oldPluginURL, newPluginURL)); 1334 1335 // Attempt to update loaded plugin (must implement Destroyable) 1336 PluginInformation tInfo = pluginsToLoad.parallelStream() 1337 .filter(x -> x.libraries.contains(newPluginURL)).findAny().orElse(null); 1338 if (tInfo != null) { 1339 Object tUpdatedPlugin = getPlugin(tInfo.name); 1340 if (tUpdatedPlugin instanceof Destroyable) { 1341 ((Destroyable) tUpdatedPlugin).destroy(); 1342 PluginHandler.loadPlugins(getInfoPanel(), Collections.singleton(tInfo), 1343 NullProgressMonitor.INSTANCE); 1344 } 1345 } 1334 1346 } catch (MalformedURLException e) { 1335 1347 Logging.warn(e); 1336 1348 }