Ignore:
Timestamp:
2017-08-01T19:38:13+02:00 (7 years ago)
Author:
Don-vip
Message:

fix #15099 - fix NPE in help browser

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/help/HelpBrowserHistory.java

    r10210 r12552  
    8080     */
    8181    public void setCurrentUrl(String url) {
    82         boolean add = true;
     82        if (url != null) {
     83            boolean add = true;
    8384
    84         if (historyPos >= 0 && historyPos < history.size() && history.get(historyPos).equals(url)) {
    85             add = false;
    86         } else if (historyPos == history.size() -1) {
    87             // do nothing just append
    88         } else if (historyPos == 0 && !history.isEmpty()) {
    89             history = new ArrayList<>(Collections.singletonList(history.get(0)));
    90         } else if (historyPos < history.size() -1 && historyPos > 0) {
    91             history = new ArrayList<>(history.subList(0, historyPos));
    92         } else {
    93             history = new ArrayList<>();
     85            if (historyPos >= 0 && historyPos < history.size() && history.get(historyPos).equals(url)) {
     86                add = false;
     87            } else if (historyPos == history.size() -1) {
     88                // do nothing just append
     89            } else if (historyPos == 0 && !history.isEmpty()) {
     90                history = new ArrayList<>(Collections.singletonList(history.get(0)));
     91            } else if (historyPos < history.size() -1 && historyPos > 0) {
     92                history = new ArrayList<>(history.subList(0, historyPos));
     93            } else {
     94                history = new ArrayList<>();
     95            }
     96            if (add) {
     97                history.add(url);
     98                historyPos = history.size()-1;
     99            }
     100            fireStateChanged();
    94101        }
    95         if (add) {
    96             history.add(url);
    97             historyPos = history.size()-1;
    98         }
    99         fireStateChanged();
    100102    }
    101103}
Note: See TracChangeset for help on using the changeset viewer.