Changeset 13330 in josm


Ignore:
Timestamp:
2018-01-15T22:52:26+01:00 (7 years ago)
Author:
Don-vip
Message:

simpler implementation of BugReportDialog.findParent()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/bugreport/BugReportDialog.java

    r12790 r13330  
    246246     */
    247247    private static Frame findParent() {
    248         Component current = Main.parent;
    249         try {
    250             // avoid cycles/invalid hirarchies
    251             for (int i = 0; i < 20 && current != null; i++) {
    252                 if (current instanceof Frame) {
    253                     return (Frame) current;
    254                 }
    255                 current = current.getParent();
    256             }
    257         } catch (RuntimeException e) { // NOPMD
    258             BugReport.intercept(e).put("current", current).warn();
    259         }
    260         return null;
     248        return (Frame) (Main.parent instanceof Frame ? Main.parent : SwingUtilities.getAncestorOfClass(Frame.class, Main.parent));
    261249    }
    262250
Note: See TracChangeset for help on using the changeset viewer.