Skip to content

Commit 6cca260

Browse files
al-nooriakoch-yatta
authored andcommitted
Quick fix for print exception of Snippet 292
The fix results from the expected behaviour of the print in Snippet 292 to redraw the control to the GC by clicking the button. This occured as a subproblem in vi-eclipse/Eclipse-Platform#501 because this worked only once. The problem is that after the first click, the label points to the image, where the group printed itself into it via the GC. Clicking a second time, the image gets disposed. Hence, when the group wants to prints again, the label cannot print its image, as it was disposed. The quick fix for it is to force the label not pointing to the image, if it has one. The question why the label is invoked to print its image, whereby not being in the hierarchy of the control (the group) is likely to be connected to an undocumented flag "OS.PW_RENDERFULLCONTENT" in OS.printWindow() which leads back to #373.
1 parent bebd1a8 commit 6cca260

File tree

1 file changed

+4
-1
lines changed
  • examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets

1 file changed

+4
-1
lines changed

examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet292.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ public static void main(String[] args) {
5454
button.setText ("Snapshot");
5555
button.addListener (SWT.Selection, e -> {
5656
Image image = label.getImage ();
57-
if (image != null) image.dispose ();
57+
if (image != null) {
58+
label.setImage(null);
59+
image.dispose ();
60+
}
5861
Rectangle rect = group.getBounds();
5962
image = new Image (display, rect.width, rect.height);
6063
GC gc = new GC (image);

0 commit comments

Comments
 (0)