Ticket #13190: patch-bug-report-add-more-reports.patch
File patch-bug-report-add-more-reports.patch, 9.5 KB (added by , 8 years ago) |
---|
-
src/org/openstreetmap/josm/gui/MapView.java
diff --git a/src/org/openstreetmap/josm/gui/MapView.java b/src/org/openstreetmap/josm/gui/MapView.java index da3079e..3f6a362 100644
a b LayerManager.LayerChangeListener, MainLayerManager.ActiveLayerChangeListener { 919 919 920 920 synchronized (temporaryLayers) { 921 921 for (MapViewPaintable mvp : temporaryLayers) { 922 mvp.paint(tempG, this, box); 922 try { 923 mvp.paint(tempG, this, box); 924 } catch (RuntimeException e) { 925 throw BugReport.intercept(e).put("mvp", mvp); 926 } 923 927 } 924 928 } 925 929 926 930 // draw world borders 931 try { 932 drawWorldBorders(tempG); 933 } catch (RuntimeException e) { 934 throw BugReport.intercept(e).put("bounds", () -> getProjection().getWorldBoundsLatLon()); 935 } 936 937 if (Main.isDisplayingMapView() && Main.map.filterDialog != null) { 938 Main.map.filterDialog.drawOSDText(tempG); 939 } 940 941 if (playHeadMarker != null) { 942 playHeadMarker.paint(tempG, this); 943 } 944 945 try { 946 g.drawImage(offscreenBuffer, 0, 0, null); 947 } catch (ClassCastException e) { 948 // See #11002 and duplicate tickets. On Linux with Java >= 8 Many users face this error here: 949 // 950 // java.lang.ClassCastException: sun.awt.image.BufImgSurfaceData cannot be cast to sun.java2d.xr.XRSurfaceData 951 // at sun.java2d.xr.XRPMBlitLoops.cacheToTmpSurface(XRPMBlitLoops.java:145) 952 // at sun.java2d.xr.XrSwToPMBlit.Blit(XRPMBlitLoops.java:353) 953 // at sun.java2d.pipe.DrawImage.blitSurfaceData(DrawImage.java:959) 954 // at sun.java2d.pipe.DrawImage.renderImageCopy(DrawImage.java:577) 955 // at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:67) 956 // at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:1014) 957 // at sun.java2d.pipe.ValidatePipe.copyImage(ValidatePipe.java:186) 958 // at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3318) 959 // at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3296) 960 // at org.openstreetmap.josm.gui.MapView.paint(MapView.java:834) 961 // 962 // It seems to be this JDK bug, but Oracle does not seem to be fixing it: 963 // https://bugs.openjdk.java.net/browse/JDK-7172749 964 // 965 // According to bug reports it can happen for a variety of reasons such as: 966 // - long period of time 967 // - change of screen resolution 968 // - addition/removal of a secondary monitor 969 // 970 // But the application seems to work fine after, so let's just log the error 971 Main.error(e); 972 } 973 super.paint(g); 974 } 975 976 private void drawWorldBorders(Graphics2D tempG) { 927 977 tempG.setColor(Color.WHITE); 928 978 Bounds b = getProjection().getWorldBoundsLatLon(); 929 979 double lat = b.getMinLat(); … … LayerManager.LayerChangeListener, MainLayerManager.ActiveLayerChangeListener { 966 1016 final Area viewport = new Area(new Rectangle(-1, -1, w + 2, h + 2)); 967 1017 border.intersect(viewport); 968 1018 tempG.draw(border); 969 970 if (Main.isDisplayingMapView() && Main.map.filterDialog != null) {971 Main.map.filterDialog.drawOSDText(tempG);972 }973 974 if (playHeadMarker != null) {975 playHeadMarker.paint(tempG, this);976 }977 978 try {979 g.drawImage(offscreenBuffer, 0, 0, null);980 } catch (ClassCastException e) {981 // See #11002 and duplicate tickets. On Linux with Java >= 8 Many users face this error here:982 //983 // java.lang.ClassCastException: sun.awt.image.BufImgSurfaceData cannot be cast to sun.java2d.xr.XRSurfaceData984 // at sun.java2d.xr.XRPMBlitLoops.cacheToTmpSurface(XRPMBlitLoops.java:145)985 // at sun.java2d.xr.XrSwToPMBlit.Blit(XRPMBlitLoops.java:353)986 // at sun.java2d.pipe.DrawImage.blitSurfaceData(DrawImage.java:959)987 // at sun.java2d.pipe.DrawImage.renderImageCopy(DrawImage.java:577)988 // at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:67)989 // at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:1014)990 // at sun.java2d.pipe.ValidatePipe.copyImage(ValidatePipe.java:186)991 // at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3318)992 // at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3296)993 // at org.openstreetmap.josm.gui.MapView.paint(MapView.java:834)994 //995 // It seems to be this JDK bug, but Oracle does not seem to be fixing it:996 // https://bugs.openjdk.java.net/browse/JDK-7172749997 //998 // According to bug reports it can happen for a variety of reasons such as:999 // - long period of time1000 // - change of screen resolution1001 // - addition/removal of a secondary monitor1002 //1003 // But the application seems to work fine after, so let's just log the error1004 Main.error(e);1005 }1006 super.paint(g);1007 1019 } 1008 1020 1009 1021 /** -
src/org/openstreetmap/josm/gui/MapViewState.java
diff --git a/src/org/openstreetmap/josm/gui/MapViewState.java b/src/org/openstreetmap/josm/gui/MapViewState.java index 3167680..6202da0 100644
a b import org.openstreetmap.josm.data.coor.EastNorth; 17 17 import org.openstreetmap.josm.data.coor.LatLon; 18 18 import org.openstreetmap.josm.data.projection.Projection; 19 19 import org.openstreetmap.josm.gui.download.DownloadDialog; 20 import org.openstreetmap.josm.tools.bugreport.BugReport; 20 21 21 22 /** 22 23 * This class represents a state of the {@link MapView}. … … public final class MapViewState { 96 97 topLeftInWindow.y += component.getY(); 97 98 component = component.getParent(); 98 99 } 99 topLeftOnScreen = position.getLocationOnScreen(); 100 try { 101 topLeftOnScreen = position.getLocationOnScreen(); 102 } catch (RuntimeException e) { 103 throw BugReport.intercept(e).put("position", position).put("parent", () -> position.getParent()); 104 } 100 105 } 101 106 102 107 private MapViewState(Projection projection, MapViewState mapViewState) { -
src/org/openstreetmap/josm/tools/bugreport/BugReport.java
diff --git a/src/org/openstreetmap/josm/tools/bugreport/BugReport.java b/src/org/openstreetmap/josm/tools/bugreport/BugReport.java index f74af94..3bc055e 100644
a b package org.openstreetmap.josm.tools.bugreport; 13 13 * <p> 14 14 * You should then add some debug information there. This can be the OSM ids that caused the error, information on the data you were working on 15 15 * or other local variables. Make sure that no excpetions may occur while computing the values. It is best to send plain local variables to 16 * put(...). Then simply throw the throwable you got from the bug report. The global exception handler will do the rest. 16 * put(...). If you need to do computations, put them into a lambda expression. Then simply throw the throwable you got from the bug report. 17 * The global exception handler will do the rest. 17 18 * <pre> 18 19 * int id = ...; 19 20 * String tag = "..."; 20 21 * try { 21 22 * ... your code ... 22 23 * } catch (Throwable t) { 23 * throw BugReport.intercept(t).put("id", id).put("tag", tag);24 * throw BugReport.intercept(t).put("id", id).put("tag", () -> x.getTag()); 24 25 * } 25 26 * </pre> 26 27 * -
src/org/openstreetmap/josm/tools/bugreport/ReportedException.java
diff --git a/src/org/openstreetmap/josm/tools/bugreport/ReportedException.java b/src/org/openstreetmap/josm/tools/bugreport/ReportedException.java index 1fe31ca..c0a79c5 100644
a b import java.util.LinkedList; 11 11 import java.util.Map; 12 12 import java.util.Map.Entry; 13 13 import java.util.Set; 14 import java.util.function.Supplier; 14 15 15 16 import org.openstreetmap.josm.Main; 16 17 … … public class ReportedException extends RuntimeException { 173 174 } 174 175 175 176 /** 176 * Adds some debug values to this exception. 177 * Adds some debug values to this exception. The value is converted to a string. Errors during conversion are handled. 177 178 * 178 179 * @param key 179 180 * The key to add this for. Does not need to be unique but it would be nice. … … public class ReportedException extends RuntimeException { 182 183 * @return This exception for easy chaining. 183 184 */ 184 185 public ReportedException put(String key, Object value) { 186 return put(key, () -> value); 187 } 188 189 /** 190 * Adds some debug values to this exception. This method automatically catches errors that occur during the production of the value. 191 * 192 * @param key 193 * The key to add this for. Does not need to be unique but it would be nice. 194 * @param valueSupplier 195 * A supplier that is called once to get the value. 196 * @return This exception for easy chaining. 197 */ 198 public ReportedException put(String key, Supplier<Object> valueSupplier) { 185 199 String string; 186 200 try { 201 Object value = valueSupplier.get(); 187 202 if (value == null) { 188 203 string = "null"; 189 204 } else if (value instanceof Collection) {