- Timestamp:
- 2019-11-04T22:19:54+01:00 (6 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java
r15121 r15508 56 56 import org.openstreetmap.josm.gui.widgets.FilterField; 57 57 import org.openstreetmap.josm.plugins.PluginDownloadTask; 58 import org.openstreetmap.josm.plugins.PluginHandler; 58 59 import org.openstreetmap.josm.plugins.PluginInformation; 59 60 import org.openstreetmap.josm.plugins.ReadLocalPluginInformationTask; … … 325 326 Collections.sort(l); 326 327 Config.getPref().putList("plugins", l); 327 if (!model.getNewlyDeactivatedPlugins().isEmpty()) 328 return true; 328 List<PluginInformation> deactivatedPlugins = model.getNewlyDeactivatedPlugins(); 329 if (!deactivatedPlugins.isEmpty()) { 330 boolean requiresRestart = PluginHandler.removePlugins(deactivatedPlugins); 331 if (requiresRestart) 332 return requiresRestart; 333 } 329 334 for (PluginInformation pi : model.getNewlyActivatedPlugins()) { 330 335 if (!pi.canloadatruntime) -
trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
r15505 r15508 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; … … 1169 1170 tr("Update plugins") 1170 1171 ); 1171 1172 1172 try { 1173 1173 pluginDownloadTask.run(); … … 1333 1333 pluginsToLoad.stream().filter(x -> x.libraries.contains(oldPluginURL)).forEach( 1334 1334 x -> Collections.replaceAll(x.libraries, oldPluginURL, newPluginURL)); 1335 1336 // Attempt to update loaded plugin (must implement Destroyable) 1337 PluginInformation tInfo = pluginsToLoad.parallelStream() 1338 .filter(x -> x.libraries.contains(newPluginURL)).findAny().orElse(null); 1339 if (tInfo != null) { 1340 Object tUpdatedPlugin = getPlugin(tInfo.name); 1341 if (tUpdatedPlugin instanceof Destroyable) { 1342 ((Destroyable) tUpdatedPlugin).destroy(); 1343 PluginHandler.loadPlugins(getInfoPanel(), Collections.singleton(tInfo), 1344 NullProgressMonitor.INSTANCE); 1345 } 1346 } 1335 1347 } catch (MalformedURLException e) { 1336 1348 Logging.warn(e); … … 1644 1656 } 1645 1657 } 1658 1659 /** 1660 * Remove deactivated plugins, returning true if JOSM should restart 1661 * 1662 * @param deactivatedPlugins The plugins to deactivate 1663 * 1664 * @return true if there was a plugin that requires a restart 1665 * @since 15508 1666 */ 1667 public static boolean removePlugins(List<PluginInformation> deactivatedPlugins) { 1668 List<Destroyable> noRestart = deactivatedPlugins.parallelStream() 1669 .map(info -> PluginHandler.getPlugin(info.name)).filter(Destroyable.class::isInstance) 1670 .map(Destroyable.class::cast).collect(Collectors.toList()); 1671 boolean restartNeeded; 1672 try { 1673 noRestart.forEach(Destroyable::destroy); 1674 new ArrayList<>(pluginList).stream().filter(proxy -> noRestart.contains(proxy.getPlugin())) 1675 .forEach(pluginList::remove); 1676 restartNeeded = deactivatedPlugins.size() != noRestart.size(); 1677 } catch (Exception e) { 1678 Logging.error(e); 1679 restartNeeded = true; 1680 } 1681 return restartNeeded; 1682 } 1646 1683 }
Note:
See TracChangeset
for help on using the changeset viewer.