Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSravan Kumar Lakkimsetti2020-05-18 10:41:57 +0000
committerSravan Kumar Lakkimsetti2020-05-18 10:41:57 +0000
commit076d14b0c9594754adf7a81d04fccd84ea8e0db2 (patch)
tree7b2dda4bc0a3bf50c073a931ffe332d1ddabb44f
parent334d975dac108357c2ae36ebdc0e62d895c44df8 (diff)
downloadeclipse.platform.swt-076d14b0c9594754adf7a81d04fccd84ea8e0db2.tar.gz
eclipse.platform.swt-076d14b0c9594754adf7a81d04fccd84ea8e0db2.tar.xz
eclipse.platform.swt-076d14b0c9594754adf7a81d04fccd84ea8e0db2.zip
Bug 563253 - [GTK][hidpi] org.eclipse.swt.graphics.GC is disposed and
destroyed when Image is re-drawn Change-Id: Ic43dc8b442ad43422ad901a18109a5282eabb457
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java20
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug563253_GraphicsSnippet.java39
2 files changed, 50 insertions, 9 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
index d865552281..1b50a3472d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
@@ -773,15 +773,17 @@ boolean refreshImageForZoom () {
currentDeviceZoom = deviceZoomLevel;
}
} else {
- int deviceZoomLevel = deviceZoom;
- if (deviceZoomLevel != currentDeviceZoom) {
- ImageData data = getImageDataAtCurrentZoom();
- destroy ();
- ImageData resizedData = DPIUtil.autoScaleImageData(device, data, deviceZoomLevel, currentDeviceZoom);
- init(resizedData);
- init();
- refreshed = true;
- currentDeviceZoom = deviceZoomLevel;
+ if (!DPIUtil.useCairoAutoScale()) {
+ int deviceZoomLevel = deviceZoom;
+ if (deviceZoomLevel != currentDeviceZoom) {
+ ImageData data = getImageDataAtCurrentZoom();
+ destroy ();
+ ImageData resizedData = DPIUtil.autoScaleImageData(device, data, deviceZoomLevel, currentDeviceZoom);
+ init(resizedData);
+ init();
+ refreshed = true;
+ currentDeviceZoom = deviceZoomLevel;
+ }
}
}
return refreshed;
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug563253_GraphicsSnippet.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug563253_GraphicsSnippet.java
new file mode 100644
index 0000000000..3ae4c1bd3e
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug563253_GraphicsSnippet.java
@@ -0,0 +1,39 @@
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+public class Bug563253_GraphicsSnippet {
+
+ public static void main(String[] args) {
+ final Display display = new Display();
+ final Shell shell = new Shell(display);
+
+ // Create image and GC for drawing
+ Image image = new Image(display, 400, 400);
+ GC gc = new GC(image);
+
+ // Paint shell
+ shell.addListener(SWT.Paint, event -> {
+ // Draw on GC
+ gc.fillRectangle(0, 0, 400, 400);
+
+ // Draw on event GC
+ event.gc.drawImage(image, 0, 0);
+ });
+
+ shell.setSize(400, 400);
+ shell.open();
+
+ while(!shell.isDisposed()) {
+ if(!display.readAndDispatch()) display.sleep();
+ }
+
+ display.dispose();
+ gc.dispose();
+ image.dispose();
+ }
+} \ No newline at end of file

Back to the top