diff options
author | Simeon Andreev | 2021-06-18 08:28:12 +0000 |
---|---|---|
committer | Andrey Loskutov | 2021-06-18 08:54:33 +0000 |
commit | 276d1bfcb909affd168a11162bc02777691a1cdc (patch) | |
tree | 8bd0fd3515b07dd8b82db5a25601d92b91ae20a5 | |
parent | bcca46688b8c8c681f0bea19c89eaf0fcab59b80 (diff) | |
download | eclipse.platform.swt-276d1bfcb909affd168a11162bc02777691a1cdc.tar.gz eclipse.platform.swt-276d1bfcb909affd168a11162bc02777691a1cdc.tar.xz eclipse.platform.swt-276d1bfcb909affd168a11162bc02777691a1cdc.zip |
Bug 573633 - Fix GLib critical errors due to unref of a null pixbuf
With the fix for bug 573633, TreeItem.setImage(null) resp.
TableItem.setImage(null) results in the following GLib critical errors
printed on standard error:
g_object_unref: assertion 'G_IS_OBJECT (object)' failed
This change adds a check, to ensure we are not calling g_object_unref()
on a null pixbuf, in TreeItem.setImage() resp. TableItem.setImage().
Change-Id: I3c081861b063affea4324c0508bfa0310e89db2a
Signed-off-by: Simeon Andreev <simeon.danailov.andreev@gmail.com>
Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/182159
Tested-by: Platform Bot <platform-bot@eclipse.org>
Reviewed-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
Reviewed-by: Andrey Loskutov <loskutov@gmx.de>
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java | 4 | ||||
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java | 4 |
2 files changed, 6 insertions, 2 deletions
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 2bf439270a..f1499752c7 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 @@ -1261,7 +1261,9 @@ public void setImage(int index, Image image) { * Bug 573633: gtk_list_store_set() will reference the handle. So we unref the pixbuf here, * and leave the destruction of the handle to be done later on by the GTK+ tree. */ - OS.g_object_unref(pixbuf); + if (pixbuf != 0) { + OS.g_object_unref(pixbuf); + } GTK.gtk_list_store_set (parent.modelHandle, handle, modelIndex + Table.CELL_SURFACE, surface, -1); cached = true; /* 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 1095828bc7..5dc6e714d9 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 @@ -1585,7 +1585,9 @@ public void setImage(int index, Image image) { * Bug 573633: gtk_tree_store_set() will reference the handle. So we unref the pixbuf here, * and leave the destruction of the handle to be done later on by the GTK+ tree. */ - OS.g_object_unref(pixbuf); + if (pixbuf != 0) { + OS.g_object_unref(pixbuf); + } GTK.gtk_tree_store_set(parent.modelHandle, handle, modelIndex + Tree.CELL_SURFACE, surface, -1); cached = true; updated = true; |