Changeset 4167 in josm


Ignore:
Timestamp:
2011-06-25T22:17:15+02:00 (13 years ago)
Author:
stoecker
Message:

fix #5975 - wrong plugin report in bug report

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r4159 r4167  
    940940     *
    941941     * @param ex the exception
    942      * @return the plugin; null, if the exception proably wasn't thrown from a plugin
     942     * @return the plugin; null, if the exception probably wasn't thrown from a plugin
    943943     */
    944944    private static PluginProxy getPluginCausingException(Throwable ex) {
     945        PluginProxy err = null;
     946        StackTraceElement[] stack = ex.getStackTrace();
     947        /* remember the error position, as multiple plugins may be involved,
     948           we search the topmost one */
     949        int pos = stack.length;
    945950        for (PluginProxy p : pluginList) {
    946951            String baseClass = p.getPluginInformation().className;
    947             int i = baseClass.lastIndexOf(".");
    948             baseClass = baseClass.substring(0, i);
    949             for (StackTraceElement element : ex.getStackTrace()) {
    950                 String c = element.getClassName();
    951                 if (c.startsWith(baseClass))
    952                     return p;
    953             }
    954         }
    955         return null;
     952            baseClass = baseClass.substring(0, baseClass.lastIndexOf("."));
     953            for (int elpos = 0; elpos < pos; ++elpos) {
     954                if (stack[elpos].getClassName().startsWith(baseClass)) {
     955                    pos = elpos;
     956                    err = p;
     957                }
     958            }
     959        }
     960        return err;
    956961    }
    957962
Note: See TracChangeset for help on using the changeset viewer.