Skip to content

Conversation

@al-noori
Copy link

@al-noori al-noori commented Nov 14, 2025

This PR results from the expected behavior of the print in Snippet 292 to redraw the control to the GC by clicking the button.

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.

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
eclipse-platform#373.
@github-actions
Copy link
Contributor

Test Results

  118 files  ±0    118 suites  ±0   15m 45s ⏱️ - 2m 30s
4 652 tests ±0  4 634 ✅  - 1  18 💤 +1  0 ❌ ±0 
  338 runs  ±0    334 ✅ ±0   4 💤 ±0  0 ❌ ±0 

Results for commit 672a1e4. ± Comparison against base commit 4241119.

This pull request skips 1 test.
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_browser_Browser_IE ‑ test_setUrl_remote_with_post

Image image = label.getImage ();
if (image != null) image.dispose ();
if (image != null) {
image.dispose ();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the order be changed - first, set label image to null and afterwards dispose the image?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exception when printing to a gc by the control class

2 participants