Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSravan Kumar Lakkimsetti2019-05-27 04:11:33 +0000
committerEric Williams2019-05-27 14:37:42 +0000
commit415f94a4ceca8db4fae42b7020da3426dd8eca5a (patch)
tree09315825546959cd5db74e53ccbd1eaabaeb3083
parent700a98588c995458d893d9288359de01e3d7e557 (diff)
downloadeclipse.platform.swt-415f94a4ceca8db4fae42b7020da3426dd8eca5a.tar.gz
eclipse.platform.swt-415f94a4ceca8db4fae42b7020da3426dd8eca5a.tar.xz
eclipse.platform.swt-415f94a4ceca8db4fae42b7020da3426dd8eca5a.zip
Bug 535741 - [HiDPI] Dozens of NPEs in LogView.onMouseMove
While updating the Image for table and tree items we resize the image as the image specified is in pixbuf instead of cairo surface. Due to this resize when we try to retrieve the image using the pixbuf stored in the imagelist it returns null. since the gtk store has resized pixbuf and imagelist has a different pixbuf. The solution is to update pixbuf array with new pixbuf and do the resize only if the image is added in the current setImage call. Otherwise we are resizing the pixbuf always (not desirable and not necessary) Tested the use case mentioned in the bug and ran full test suite at 200% and ran Manual Junit tests for tree and table Change-Id: Iba6fbabd99a9660c79d13abd1ebdae28ac2012ba Signed-off-by: Sravan Kumar Lakkimsetti <sravankumarl@in.ibm.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java29
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java59
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java59
4 files changed, 94 insertions, 59 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java
index e2eefc55c9..4f1122b273 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/ImageList.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -204,6 +204,10 @@ public void remove (Image image) {
}
}
+public void replacePixbuf (int index, long pixbuf) {
+ pixbufs[index] = pixbuf;
+}
+
void set (int index, Image image) {
long pixbuf = createPixbuf (image);
int w = GDK.gdk_pixbuf_get_width(pixbuf);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java
index 1d8dea5d57..81196176f5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MenuItem.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -833,18 +833,29 @@ public void setImage (Image image) {
ImageList imageList = parent.imageList;
if (imageList == null) imageList = parent.imageList = new ImageList ();
int imageIndex = imageList.indexOf (image);
+ long pixbuf = 0;
if (imageIndex == -1) {
imageIndex = imageList.add (image);
+ pixbuf = imageList.getPixbuf (imageIndex);
+ /*
+ * Bug in GTK the default renderer does scale again on pixbuf.
+ * Need to scaledown here and no need to scaledown id device scale is 1
+ *
+ * We should resize pixbuf and update pixbuf array in the imagelist only if
+ * the image is added to the imagelist in this call. If the image is already
+ * add imageList.getPixbuf returns resized pixbuf.
+ */
+ if (DPIUtil.useCairoAutoScale()) {
+ Rectangle imgSize = image.getBounds();
+ long scaledPixbuf = GDK.gdk_pixbuf_scale_simple(pixbuf, imgSize.width, imgSize.height, GDK.GDK_INTERP_BILINEAR);
+ if (scaledPixbuf !=0) {
+ pixbuf = scaledPixbuf;
+ }
+ imageList.replacePixbuf(imageIndex, pixbuf);
+ }
} else {
imageList.put (imageIndex, image);
- }
- long pixbuf = imageList.getPixbuf (imageIndex);
- if (DPIUtil.useCairoAutoScale()) {
- Rectangle imgSize = image.getBounds();
- long scaledPixbuf = GDK.gdk_pixbuf_scale_simple(pixbuf, imgSize.width, imgSize.height, GDK.GDK_INTERP_BILINEAR);
- if (scaledPixbuf !=0) {
- pixbuf = scaledPixbuf;
- }
+ pixbuf = imageList.getPixbuf (imageIndex);
}
if (!GTK.GTK_IS_MENU_ITEM (handle)) return;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java
index e3f8da966c..197c856f05 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -1199,32 +1199,43 @@ public void setImage (int index, Image image) {
ImageList imageList = parent.imageList;
if (imageList == null) imageList = parent.imageList = new ImageList ();
int imageIndex = imageList.indexOf (image);
- if (imageIndex == -1) imageIndex = imageList.add (image);
- pixbuf = imageList.getPixbuf (imageIndex);
- }
- /*
- * Reset size of pixbufRenderer if we have an image being set that is larger
- * than the current size of the pixbufRenderer. Fix for bug 457196.
- * We only do this if the size of the pixbufRenderer has not yet been set.
- * Otherwise, the pixbufRenderer retains the same size as the first image added.
- * See comment #4, Bug 478560. Note that all columns need to have their
- * pixbufRenderer set to this size after the initial image is set. NOTE: this
- * change has been ported to Tables since Tables/Trees both use the same
- * underlying GTK structure.
- */
- if (DPIUtil.useCairoAutoScale()) {
- /*
- * Bug in GTK the default renderer does scale again on pixbuf.
- * Need to scaledown here and no need to scaledown id device scale is 1
- */
- if ((!parent.ownerDraw) && (image != null) && (DPIUtil.getDeviceZoom() != 100)) {
- Rectangle imgSize = image.getBounds();
- long scaledPixbuf = GDK.gdk_pixbuf_scale_simple(pixbuf, imgSize.width, imgSize.height, GDK.GDK_INTERP_BILINEAR);
- if (scaledPixbuf !=0) {
- pixbuf = scaledPixbuf;
+ if (imageIndex == -1) {
+ imageIndex = imageList.add (image);
+ pixbuf = imageList.getPixbuf (imageIndex);
+ /*
+ * Reset size of pixbufRenderer if we have an image being set that is larger
+ * than the current size of the pixbufRenderer. Fix for bug 457196.
+ * We only do this if the size of the pixbufRenderer has not yet been set.
+ * Otherwise, the pixbufRenderer retains the same size as the first image added.
+ * See comment #4, Bug 478560. Note that all columns need to have their
+ * pixbufRenderer set to this size after the initial image is set. NOTE: this
+ * change has been ported to Tables since Tables/Trees both use the same
+ * underlying GTK structure.
+ */
+ if (DPIUtil.useCairoAutoScale()) {
+ /*
+ * Bug in GTK the default renderer does scale again on pixbuf.
+ * Need to scaledown here and no need to scaledown id device scale is 1
+ *
+ * We should resize pixbuf and update pixbuf array in the imagelist only if
+ * the image is added to the imagelist in this call. If the image is already
+ * add imageList.getPixbuf returns resized pixbuf.
+ */
+
+ if ((!parent.ownerDraw) && (DPIUtil.getDeviceZoom() != 100)) {
+ Rectangle imgSize = image.getBounds();
+ long scaledPixbuf = GDK.gdk_pixbuf_scale_simple(pixbuf, imgSize.width, imgSize.height, GDK.GDK_INTERP_BILINEAR);
+ if (scaledPixbuf !=0) {
+ pixbuf = scaledPixbuf;
+ }
+ imageList.replacePixbuf(imageIndex, pixbuf);
+ }
}
+ } else {
+ pixbuf = imageList.getPixbuf (imageIndex);
}
}
+
long parentHandle = parent.handle;
long column = GTK.gtk_tree_view_get_column (parentHandle, index);
long pixbufRenderer = parent.getPixbufRenderer (column);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
index e54631f4b8..4a49ba02bb 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -1537,33 +1537,42 @@ public void setImage (int index, Image image) {
ImageList imageList = parent.imageList;
if (imageList == null) imageList = parent.imageList = new ImageList ();
int imageIndex = imageList.indexOf (image);
- if (imageIndex == -1) imageIndex = imageList.add (image);
- pixbuf = imageList.getPixbuf (imageIndex);
- }
- int modelIndex = parent.columnCount == 0 ? Tree.FIRST_COLUMN : parent.columns [index].modelIndex;
- /*
- * Reset size of pixbufRenderer if we have an image being set that is larger
- * than the current size of the pixbufRenderer. Fix for Bug 469277 & 476419.
- * We only do this if the size of the pixbufRenderer has not yet been set.
- * Otherwise, the pixbufRenderer retains the same size as the first image added.
- * See comment #4, Bug 478560. Note that all columns need to have their
- * pixbufRenderer set to this size after the initial image is set. NOTE: this
- * change has been ported to Tables since Tables/Trees both use the same
- * underlying GTK structure.
- */
- if (DPIUtil.useCairoAutoScale()) {
- /*
- * Bug in GTK the default renderer does scale again on pixbuf.
- * Need to scaledown here and no need to scaledown id device scale is 1
- */
- if ((!parent.ownerDraw) && (image != null) && (DPIUtil.getDeviceZoom() != 100)) {
- Rectangle imgSize = image.getBounds();
- long scaledPixbuf = GDK.gdk_pixbuf_scale_simple(pixbuf, imgSize.width, imgSize.height, GDK.GDK_INTERP_BILINEAR);
- if (scaledPixbuf !=0) {
- pixbuf = scaledPixbuf;
+ if (imageIndex == -1) {
+ imageIndex = imageList.add (image);
+ pixbuf = imageList.getPixbuf (imageIndex);
+ /*
+ * Reset size of pixbufRenderer if we have an image being set that is larger
+ * than the current size of the pixbufRenderer. Fix for Bug 469277 & 476419.
+ * We only do this if the size of the pixbufRenderer has not yet been set.
+ * Otherwise, the pixbufRenderer retains the same size as the first image added.
+ * See comment #4, Bug 478560. Note that all columns need to have their
+ * pixbufRenderer set to this size after the initial image is set. NOTE: this
+ * change has been ported to Tables since Tables/Trees both use the same
+ * underlying GTK structure.
+ */
+ if (DPIUtil.useCairoAutoScale()) {
+ /*
+ * Bug in GTK the default renderer does scale again on pixbuf.
+ * Need to scaledown here and no need to scaledown id device scale is 1
+ *
+ * We should resize pixbuf and update pixbuf array in the imagelist only if
+ * the image is added to the imagelist in this call. If the image is already
+ * add imageList.getPixbuf returns resized pixbuf.
+ */
+ if ((!parent.ownerDraw) && (image != null) && (DPIUtil.getDeviceZoom() != 100)) {
+ Rectangle imgSize = image.getBounds();
+ long scaledPixbuf = GDK.gdk_pixbuf_scale_simple(pixbuf, imgSize.width, imgSize.height, GDK.GDK_INTERP_BILINEAR);
+ if (scaledPixbuf !=0) {
+ pixbuf = scaledPixbuf;
+ }
+ imageList.replacePixbuf(imageIndex, pixbuf);
+ }
}
+ } else {
+ pixbuf = imageList.getPixbuf (imageIndex);
}
}
+ int modelIndex = parent.columnCount == 0 ? Tree.FIRST_COLUMN : parent.columns [index].modelIndex;
long parentHandle = parent.handle;
long column = GTK.gtk_tree_view_get_column (parentHandle, index);
long pixbufRenderer = parent.getPixbufRenderer (column);

Back to the top