6653511: JComponent.safelyGetGraphics() may sometimes return null
Reviewed-by: rupashka
--- a/jdk/src/share/classes/javax/swing/JComponent.java Thu Mar 03 16:40:13 2011 +0300
+++ b/jdk/src/share/classes/javax/swing/JComponent.java Thu Mar 03 18:23:19 2011 +0300
@@ -5158,31 +5158,30 @@
}
}
}
-
try {
- g = safelyGetGraphics(paintingComponent, c);
- try {
- if (hasBuffer) {
- RepaintManager rm = RepaintManager.currentManager(
- bufferedComponent);
- rm.beginPaint();
- try {
- rm.paint(paintingComponent, bufferedComponent, g,
- paintImmediatelyClip.x,
- paintImmediatelyClip.y,
- paintImmediatelyClip.width,
- paintImmediatelyClip.height);
- } finally {
- rm.endPaint();
+ if ((g = safelyGetGraphics(paintingComponent, c)) != null) {
+ try {
+ if (hasBuffer) {
+ RepaintManager rm = RepaintManager.currentManager(
+ bufferedComponent);
+ rm.beginPaint();
+ try {
+ rm.paint(paintingComponent, bufferedComponent, g,
+ paintImmediatelyClip.x,
+ paintImmediatelyClip.y,
+ paintImmediatelyClip.width,
+ paintImmediatelyClip.height);
+ } finally {
+ rm.endPaint();
+ }
+ } else {
+ g.setClip(paintImmediatelyClip.x, paintImmediatelyClip.y,
+ paintImmediatelyClip.width, paintImmediatelyClip.height);
+ paintingComponent.paint(g);
}
+ } finally {
+ g.dispose();
}
- else {
- g.setClip(paintImmediatelyClip.x,paintImmediatelyClip.y,
- paintImmediatelyClip.width,paintImmediatelyClip.height);
- paintingComponent.paint(g);
- }
- } finally {
- g.dispose();
}
}
finally {