Skip to content

Commit 323f79d

Browse files
committed
FormText.paint(): don't pass (0,0) to Image constructor
Fixes #3087
1 parent d2177cf commit 323f79d

File tree

1 file changed

+8
-1
lines changed
  • bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets

1 file changed

+8
-1
lines changed

bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/FormText.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1555,7 +1555,14 @@ private void paint(PaintEvent e) {
15551555
gc.setForeground(getForeground());
15561556
gc.setBackground(getBackground());
15571557
Point size = getSize();
1558-
repaint(gc, 0, 0, size.x, size.y);
1558+
Rectangle paintBounds;
1559+
if (size.x == 0 && size.y == 0) {
1560+
// avoids crash on image creation with (0,0) image size
1561+
paintBounds = new Rectangle(e.x, e.y, e.width, e.height);
1562+
} else {
1563+
paintBounds = new Rectangle(0, 0, size.x, size.y);
1564+
}
1565+
repaint(gc, paintBounds.x, paintBounds.y, paintBounds.width, paintBounds.height);
15591566
}
15601567

15611568
private void repaint(GC gc, int x, int y, int width, int height) {

0 commit comments

Comments
 (0)