Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Williams2019-04-11 13:10:22 -0400
committerEric Williams2019-04-23 15:49:19 -0400
commit28c0ebeec7b72594bb128701ccaa5f4caf7f49f2 (patch)
tree7ecaffc6aff998efa38c447924e6f95a848fdbc6
parent334542aecfe5ad8883b94a07a4a93b1a4e50d383 (diff)
downloadeclipse.platform.swt-28c0ebeec7b72594bb128701ccaa5f4caf7f49f2.tar.gz
eclipse.platform.swt-28c0ebeec7b72594bb128701ccaa5f4caf7f49f2.tar.xz
eclipse.platform.swt-28c0ebeec7b72594bb128701ccaa5f4caf7f49f2.zip
Bug 546349: [Wayland] Prevent GtkIMContext crashes/warnings
Check the imHandle before calling gtk_im_context_reset(). Change-Id: I1cfc46ffeb1ff66d9ceca2415213364826451032 Signed-off-by: Eric Williams <ericwill@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java9
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java2
5 files changed, 24 insertions, 1 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
index fc8e175759..1848fb0348 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
@@ -3653,6 +3653,18 @@ JNIEXPORT jboolean JNICALL GTK_NATIVE(_1GTK_1IS_1CONTAINER)
}
#endif
+#ifndef NO__1GTK_1IS_1IM_1CONTEXT
+JNIEXPORT jboolean JNICALL GTK_NATIVE(_1GTK_1IS_1IM_1CONTEXT)
+ (JNIEnv *env, jclass that, jlong arg0)
+{
+ jboolean rc = 0;
+ GTK_NATIVE_ENTER(env, that, _1GTK_1IS_1IM_1CONTEXT_FUNC);
+ rc = (jboolean)GTK_IS_IM_CONTEXT(arg0);
+ GTK_NATIVE_EXIT(env, that, _1GTK_1IS_1IM_1CONTEXT_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1GTK_1IS_1LABEL
JNIEXPORT jboolean JNICALL GTK_NATIVE(_1GTK_1IS_1LABEL)
(JNIEnv *env, jclass that, jlong arg0)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
index 60c364f933..ef46e89be3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
@@ -313,6 +313,7 @@ char * GTK_nativeFunctionNames[] = {
"_1GTK_1IS_1CELL_1RENDERER_1TEXT",
"_1GTK_1IS_1CELL_1RENDERER_1TOGGLE",
"_1GTK_1IS_1CONTAINER",
+ "_1GTK_1IS_1IM_1CONTEXT",
"_1GTK_1IS_1LABEL",
"_1GTK_1IS_1MENU_1ITEM",
"_1GTK_1IS_1PLUG",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
index 63a4a35b38..7e6d144d0b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
@@ -311,6 +311,7 @@ typedef enum {
_1GTK_1IS_1CELL_1RENDERER_1TEXT_FUNC,
_1GTK_1IS_1CELL_1RENDERER_1TOGGLE_FUNC,
_1GTK_1IS_1CONTAINER_FUNC,
+ _1GTK_1IS_1IM_1CONTEXT_FUNC,
_1GTK_1IS_1LABEL_FUNC,
_1GTK_1IS_1MENU_1ITEM_FUNC,
_1GTK_1IS_1PLUG_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
index 66c9cb1cb6..fa288104ba 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
@@ -287,6 +287,15 @@ public class GTK extends OS {
lock.unlock();
}
}
+ public static final native boolean _GTK_IS_IM_CONTEXT(long obj);
+ public static final boolean GTK_IS_IM_CONTEXT(long obj) {
+ lock.lock();
+ try {
+ return _GTK_IS_IM_CONTEXT(obj);
+ } finally {
+ lock.unlock();
+ }
+ }
public static final native boolean _GTK_IS_SCROLLED_WINDOW(long obj);
public static final boolean GTK_IS_SCROLLED_WINDOW(long obj) {
lock.lock();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
index 0dda66274d..9e4d812c77 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
@@ -4620,7 +4620,7 @@ void releaseWidget () {
redrawSurface = 0;
} else {
long imHandle = imHandle ();
- if (imHandle != 0) {
+ if (imHandle != 0 && GTK.GTK_IS_IM_CONTEXT(imHandle)) {
GTK.gtk_im_context_reset (imHandle);
GTK.gtk_im_context_set_client_window (imHandle, 0);
}

Back to the top