Skip to content

Commit

Permalink
fixes bug that prevented opening the maps and themes more than once
Browse files Browse the repository at this point in the history
  • Loading branch information
cpesch committed Sep 10, 2024
1 parent 4ddacd1 commit e241dc0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ public void register(String actionName, Action action) {
}
}

public void unregister(String actionName) {
Action found = actionMap.get(actionName);
if (found != null)
actionMap.remove(actionName);
ProxyAction proxyAction = proxyActionMap.get(actionName);
if (proxyAction != null)
proxyAction.setDelegate(null);
}

public void registerLocal(String globalName, String localName, String actionName) {
GlobalAction found = (GlobalAction) actionMap.get(globalName);
if (found == null)
Expand Down Expand Up @@ -159,11 +168,12 @@ private ProxyAction(Action delegate) {

public void setDelegate(Action delegate) {
if (this.delegate != null)
delegate.removePropertyChangeListener(this);
this.delegate.removePropertyChangeListener(this);

this.delegate = delegate;

delegate.addPropertyChangeListener(this);
if (this.delegate != null)
this.delegate.addPropertyChangeListener(this);
}

public void propertyChange(PropertyChangeEvent evt) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,14 @@ private MapsforgeMapManager getMapsforgeMapManager() {
}

private void close() {
RouteConverter.getInstance().showMapBorder(null);
RouteConverter r = RouteConverter.getInstance();
r.showMapBorder(null);

ActionManager actionManager = r.getContext().getActionManager();
actionManager.unregister("display-online-map");
actionManager.unregister("display-offline-map");
actionManager.unregister("delete-offline-maps");
actionManager.unregister("download-maps");
dispose();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ private MapsforgeMapManager getMapsforgeMapManager() {
}

private void close() {
ActionManager actionManager = RouteConverter.getInstance().getContext().getActionManager();
actionManager.unregister("apply-theme");
actionManager.unregister("download-themes");

dispose();
}

Expand Down

0 comments on commit e241dc0

Please sign in to comment.