Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilenio Quarti2011-04-01 19:52:31 +0000
committerSilenio Quarti2011-04-01 19:52:31 +0000
commit52c110b93169ca50cc17336de89321eb76b5f3d3 (patch)
tree624a8a7a9fdfe8cf9baf1cf53e014d1bb048c0c3
parentea1614638a2d49cacb0be9856960133527b7df52 (diff)
downloadeclipse.platform.swt-52c110b93169ca50cc17336de89321eb76b5f3d3.tar.gz
eclipse.platform.swt-52c110b93169ca50cc17336de89321eb76b5f3d3.tar.xz
eclipse.platform.swt-52c110b93169ca50cc17336de89321eb76b5f3d3.zip
Bug 341085 - swt tests timing out linux.gtk.x86 in N20110327-2000
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/Clipboard.java28
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Mozilla/carbon/org/eclipse/swt/browser/MozillaDelegate.java3
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Mozilla/cocoa/org/eclipse/swt/browser/MozillaDelegate.java3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java21
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Mozilla/gtk/org/eclipse/swt/browser/MozillaDelegate.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Mozilla/motif/org/eclipse/swt/browser/MozillaDelegate.java3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Mozilla/win32/org/eclipse/swt/browser/MozillaDelegate.java3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c238
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c23
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h19
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/Lock.java35
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java91
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/PrintDialog.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/Printer.java21
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java82
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ColorDialog.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DirectoryDialog.java14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java110
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MessageBox.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java7
-rw-r--r--bundles/org.eclipse.swt/tasks/build.xml2
23 files changed, 445 insertions, 308 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/Clipboard.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/Clipboard.java
index 87b1e171ce..d1f88bc58b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/Clipboard.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/Clipboard.java
@@ -292,10 +292,24 @@ public Object getContents(Transfer transfer, int clipboards) {
for (int i = 0; i < typeIds.length; i++) {
if ((clipboards & DND.CLIPBOARD) != 0) {
selection_data = gtk_clipboard_wait_for_contents(GTKCLIPBOARD, typeIds[i]);
+ /*
+ * This call to gdk_threads_leave() is a temporary work around
+ * to avoid deadlocks when gdk_threads_init() is called by native
+ * code outside of SWT (i.e AWT, etc). It ensures that the current
+ * thread leaves the GTK lock acquired by the function above.
+ */
+ OS.gdk_threads_leave();
}
if (selection_data != 0) break;
if ((clipboards & DND.SELECTION_CLIPBOARD) != 0) {
selection_data = gtk_clipboard_wait_for_contents(GTKPRIMARYCLIPBOARD, typeIds[i]);
+ /*
+ * This call to gdk_threads_leave() is a temporary work around
+ * to avoid deadlocks when gdk_threads_init() is called by native
+ * code outside of SWT (i.e AWT, etc). It ensures that the current
+ * thread leaves the GTK lock acquired by the function above.
+ */
+ OS.gdk_threads_leave();
}
}
if (selection_data == 0) return null;
@@ -579,6 +593,13 @@ public String[] getAvailableTypeNames() {
private int[] getAvailablePrimaryTypes() {
int[] types = new int[0];
int /*long*/ selection_data = gtk_clipboard_wait_for_contents(GTKPRIMARYCLIPBOARD, TARGET);
+ /*
+ * This call to gdk_threads_leave() is a temporary work around
+ * to avoid deadlocks when gdk_threads_init() is called by native
+ * code outside of SWT (i.e AWT, etc). It ensures that the current
+ * thread leaves the GTK lock acquired by the function above.
+ */
+ OS.gdk_threads_leave();
if (selection_data != 0) {
try {
GtkSelectionData gtkSelectionData = new GtkSelectionData();
@@ -596,6 +617,13 @@ private int[] getAvailablePrimaryTypes() {
private int[] getAvailableClipboardTypes () {
int[] types = new int[0];
int /*long*/ selection_data = gtk_clipboard_wait_for_contents(GTKCLIPBOARD, TARGET);
+ /*
+ * This call to gdk_threads_leave() is a temporary work around
+ * to avoid deadlocks when gdk_threads_init() is called by native
+ * code outside of SWT (i.e AWT, etc). It ensures that the current
+ * thread leaves the GTK lock acquired by the function above.
+ */
+ OS.gdk_threads_leave();
if (selection_data != 0) {
try {
GtkSelectionData gtkSelectionData = new GtkSelectionData();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/carbon/org/eclipse/swt/browser/MozillaDelegate.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/carbon/org/eclipse/swt/browser/MozillaDelegate.java
index 05aa356440..16b769db33 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/carbon/org/eclipse/swt/browser/MozillaDelegate.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/carbon/org/eclipse/swt/browser/MozillaDelegate.java
@@ -45,9 +45,6 @@ static String getLibraryName () {
return "libxpcom.dylib"; //$NON-NLS-1$
}
-static void lock (boolean lock) {
-}
-
static char[] mbcsToWcs (String codePage, byte [] buffer) {
int encoding = OS.CFStringGetSystemEncoding ();
int cfstring = OS.CFStringCreateWithBytes (OS.kCFAllocatorDefault, buffer, buffer.length, encoding, false);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/cocoa/org/eclipse/swt/browser/MozillaDelegate.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/cocoa/org/eclipse/swt/browser/MozillaDelegate.java
index e5bd5724aa..40ef94fc13 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/cocoa/org/eclipse/swt/browser/MozillaDelegate.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/cocoa/org/eclipse/swt/browser/MozillaDelegate.java
@@ -36,9 +36,6 @@ static String getLibraryName () {
return "libxpcom.dylib"; //$NON-NLS-1$
}
-static void lock (boolean lock) {
-}
-
static char[] mbcsToWcs (String codePage, byte [] buffer) {
// int encoding = OS.CFStringGetSystemEncoding ();
// int cfstring = OS.CFStringCreateWithBytes (OS.kCFAllocatorDefault, buffer, buffer.length, encoding, false);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java
index 95be02b0a6..6532ba8bba 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/common/org/eclipse/swt/browser/Mozilla.java
@@ -137,16 +137,7 @@ class Mozilla extends WebBrowser {
int length = SHUTDOWN_PERSIST.length ();
char[] chars = new char [length + 1];
SHUTDOWN_PERSIST.getChars (0, length, chars, 0);
- /*
- * NotifyObservers is calling g_main_context_iteration() during shutdown. Need
- * to leave GDK mutex since it is not reentrant.
- */
- try {
- MozillaDelegate.lock(false);
- rc = observerService.NotifyObservers (0, buffer, chars);
- } finally {
- MozillaDelegate.lock(true);
- }
+ rc = observerService.NotifyObservers (0, buffer, chars);
if (rc != XPCOM.NS_OK) error (rc);
observerService.Release ();
@@ -3778,14 +3769,8 @@ int SetVisibility (int aVisibility) {
event.menuBar = isOSX || (chromeFlags & nsIWebBrowserChrome.CHROME_MENUBAR) != 0;
event.statusBar = (chromeFlags & nsIWebBrowserChrome.CHROME_STATUSBAR) != 0;
event.toolBar = (chromeFlags & nsIWebBrowserChrome.CHROME_TOOLBAR) != 0;
- /* TEMPORARY CODE */
- MozillaDelegate.lock (true);
- try {
- for (int i = 0; i < visibilityWindowListeners.length; i++) {
- visibilityWindowListeners[i].show (event);
- }
- } finally {
- MozillaDelegate.lock (false);
+ for (int i = 0; i < visibilityWindowListeners.length; i++) {
+ visibilityWindowListeners[i].show (event);
}
location = null;
size = null;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/gtk/org/eclipse/swt/browser/MozillaDelegate.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/gtk/org/eclipse/swt/browser/MozillaDelegate.java
index 5dcc900362..e2dda62421 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/gtk/org/eclipse/swt/browser/MozillaDelegate.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/gtk/org/eclipse/swt/browser/MozillaDelegate.java
@@ -72,14 +72,6 @@ static String getLibraryName () {
return "libxpcom.so"; //$NON-NLS-1$
}
-static void lock (boolean lock) {
- if (lock) {
- OS.gdk_threads_enter();
- } else {
- OS.gdk_threads_leave();
- }
-}
-
static char[] mbcsToWcs (String codePage, byte [] buffer) {
return Converter.mbcsToWcs (codePage, buffer);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/motif/org/eclipse/swt/browser/MozillaDelegate.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/motif/org/eclipse/swt/browser/MozillaDelegate.java
index 21a58e4b81..3a6c5bdd27 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/motif/org/eclipse/swt/browser/MozillaDelegate.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/motif/org/eclipse/swt/browser/MozillaDelegate.java
@@ -81,9 +81,6 @@ static String getLibraryName () {
return "libxpcom.so"; //$NON-NLS-1$
}
-static void lock (boolean lock) {
-}
-
static char[] mbcsToWcs (String codePage, byte [] buffer) {
return Converter.mbcsToWcs (codePage, buffer);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/win32/org/eclipse/swt/browser/MozillaDelegate.java b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/win32/org/eclipse/swt/browser/MozillaDelegate.java
index 344b18cc4a..f7bb342053 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Mozilla/win32/org/eclipse/swt/browser/MozillaDelegate.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Mozilla/win32/org/eclipse/swt/browser/MozillaDelegate.java
@@ -35,9 +35,6 @@ static String getLibraryName () {
return "xpcom.dll"; //$NON-NLS-1$
}
-static void lock (boolean lock) {
-}
-
static char[] mbcsToWcs (String codePage, byte[] buffer) {
char[] chars = new char[buffer.length];
int charCount = OS.MultiByteToWideChar (OS.CP_ACP, OS.MB_PRECOMPOSED, buffer, buffer.length, chars, chars.length);
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 bdb653e45d..9346485251 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
@@ -3555,6 +3555,120 @@ fail:
}
#endif
+#ifndef NO__1g_1main_1context_1acquire
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1g_1main_1context_1acquire)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jboolean rc = 0;
+ OS_NATIVE_ENTER(env, that, _1g_1main_1context_1acquire_FUNC);
+ rc = (jboolean)g_main_context_acquire((GMainContext *)arg0);
+ OS_NATIVE_EXIT(env, that, _1g_1main_1context_1acquire_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1g_1main_1context_1check
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1main_1context_1check)
+ (JNIEnv *env, jclass that, jintLong arg0, jint arg1, jintLong arg2, jint arg3)
+{
+ jint rc = 0;
+ OS_NATIVE_ENTER(env, that, _1g_1main_1context_1check_FUNC);
+ rc = (jint)g_main_context_check((GMainContext *)arg0, arg1, (GPollFD *)arg2, arg3);
+ OS_NATIVE_EXIT(env, that, _1g_1main_1context_1check_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1g_1main_1context_1default
+JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1main_1context_1default)
+ (JNIEnv *env, jclass that)
+{
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, _1g_1main_1context_1default_FUNC);
+ rc = (jintLong)g_main_context_default();
+ OS_NATIVE_EXIT(env, that, _1g_1main_1context_1default_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1g_1main_1context_1get_1poll_1func
+JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1main_1context_1get_1poll_1func)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, _1g_1main_1context_1get_1poll_1func_FUNC);
+ rc = (jintLong)g_main_context_get_poll_func((GMainContext *)arg0);
+ OS_NATIVE_EXIT(env, that, _1g_1main_1context_1get_1poll_1func_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1g_1main_1context_1iteration
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1g_1main_1context_1iteration)
+ (JNIEnv *env, jclass that, jintLong arg0, jboolean arg1)
+{
+ jboolean rc = 0;
+ OS_NATIVE_ENTER(env, that, _1g_1main_1context_1iteration_FUNC);
+ rc = (jboolean)g_main_context_iteration((GMainContext *)arg0, arg1);
+ OS_NATIVE_EXIT(env, that, _1g_1main_1context_1iteration_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1g_1main_1context_1pending
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1g_1main_1context_1pending)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jboolean rc = 0;
+ OS_NATIVE_ENTER(env, that, _1g_1main_1context_1pending_FUNC);
+ rc = (jboolean)g_main_context_pending((GMainContext *)arg0);
+ OS_NATIVE_EXIT(env, that, _1g_1main_1context_1pending_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1g_1main_1context_1prepare
+JNIEXPORT jboolean JNICALL OS_NATIVE(_1g_1main_1context_1prepare)
+ (JNIEnv *env, jclass that, jintLong arg0, jintArray arg1)
+{
+ jint *lparg1=NULL;
+ jboolean rc = 0;
+ OS_NATIVE_ENTER(env, that, _1g_1main_1context_1prepare_FUNC);
+ if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
+ rc = (jboolean)g_main_context_prepare((GMainContext *)arg0, lparg1);
+fail:
+ if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
+ OS_NATIVE_EXIT(env, that, _1g_1main_1context_1prepare_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1g_1main_1context_1query
+JNIEXPORT jint JNICALL OS_NATIVE(_1g_1main_1context_1query)
+ (JNIEnv *env, jclass that, jintLong arg0, jint arg1, jintArray arg2, jintLong arg3, jint arg4)
+{
+ jint *lparg2=NULL;
+ jint rc = 0;
+ OS_NATIVE_ENTER(env, that, _1g_1main_1context_1query_FUNC);
+ if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
+ rc = (jint)g_main_context_query((GMainContext *)arg0, arg1, lparg2, (GPollFD *)arg3, arg4);
+fail:
+ if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
+ OS_NATIVE_EXIT(env, that, _1g_1main_1context_1query_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1g_1main_1context_1release
+JNIEXPORT void JNICALL OS_NATIVE(_1g_1main_1context_1release)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ OS_NATIVE_ENTER(env, that, _1g_1main_1context_1release_FUNC);
+ g_main_context_release((GMainContext *)arg0);
+ OS_NATIVE_EXIT(env, that, _1g_1main_1context_1release_FUNC);
+}
+#endif
+
#ifndef NO__1g_1malloc
JNIEXPORT jintLong JNICALL OS_NATIVE(_1g_1malloc)
(JNIEnv *env, jclass that, jintLong arg0)
@@ -18421,120 +18535,6 @@ JNIEXPORT void JNICALL OS_NATIVE(_1pango_1tab_1array_1set_1tab)
}
#endif
-#ifndef NO_g_1main_1context_1acquire
-JNIEXPORT jboolean JNICALL OS_NATIVE(g_1main_1context_1acquire)
- (JNIEnv *env, jclass that, jintLong arg0)
-{
- jboolean rc = 0;
- OS_NATIVE_ENTER(env, that, g_1main_1context_1acquire_FUNC);
- rc = (jboolean)g_main_context_acquire((GMainContext *)arg0);
- OS_NATIVE_EXIT(env, that, g_1main_1context_1acquire_FUNC);
- return rc;
-}
-#endif
-
-#ifndef NO_g_1main_1context_1check
-JNIEXPORT jint JNICALL OS_NATIVE(g_1main_1context_1check)
- (JNIEnv *env, jclass that, jintLong arg0, jint arg1, jintLong arg2, jint arg3)
-{
- jint rc = 0;
- OS_NATIVE_ENTER(env, that, g_1main_1context_1check_FUNC);
- rc = (jint)g_main_context_check((GMainContext *)arg0, arg1, (GPollFD *)arg2, arg3);
- OS_NATIVE_EXIT(env, that, g_1main_1context_1check_FUNC);
- return rc;
-}
-#endif
-
-#ifndef NO_g_1main_1context_1default
-JNIEXPORT jintLong JNICALL OS_NATIVE(g_1main_1context_1default)
- (JNIEnv *env, jclass that)
-{
- jintLong rc = 0;
- OS_NATIVE_ENTER(env, that, g_1main_1context_1default_FUNC);
- rc = (jintLong)g_main_context_default();
- OS_NATIVE_EXIT(env, that, g_1main_1context_1default_FUNC);
- return rc;
-}
-#endif
-
-#ifndef NO_g_1main_1context_1get_1poll_1func
-JNIEXPORT jintLong JNICALL OS_NATIVE(g_1main_1context_1get_1poll_1func)
- (JNIEnv *env, jclass that, jintLong arg0)
-{
- jintLong rc = 0;
- OS_NATIVE_ENTER(env, that, g_1main_1context_1get_1poll_1func_FUNC);
- rc = (jintLong)g_main_context_get_poll_func((GMainContext *)arg0);
- OS_NATIVE_EXIT(env, that, g_1main_1context_1get_1poll_1func_FUNC);
- return rc;
-}
-#endif
-
-#ifndef NO_g_1main_1context_1iteration
-JNIEXPORT jboolean JNICALL OS_NATIVE(g_1main_1context_1iteration)
- (JNIEnv *env, jclass that, jintLong arg0, jboolean arg1)
-{
- jboolean rc = 0;
- OS_NATIVE_ENTER(env, that, g_1main_1context_1iteration_FUNC);
- rc = (jboolean)g_main_context_iteration((GMainContext *)arg0, arg1);
- OS_NATIVE_EXIT(env, that, g_1main_1context_1iteration_FUNC);
- return rc;
-}
-#endif
-
-#ifndef NO_g_1main_1context_1pending
-JNIEXPORT jboolean JNICALL OS_NATIVE(g_1main_1context_1pending)
- (JNIEnv *env, jclass that, jintLong arg0)
-{
- jboolean rc = 0;
- OS_NATIVE_ENTER(env, that, g_1main_1context_1pending_FUNC);
- rc = (jboolean)g_main_context_pending((GMainContext *)arg0);
- OS_NATIVE_EXIT(env, that, g_1main_1context_1pending_FUNC);
- return rc;
-}
-#endif
-
-#ifndef NO_g_1main_1context_1prepare
-JNIEXPORT jboolean JNICALL OS_NATIVE(g_1main_1context_1prepare)
- (JNIEnv *env, jclass that, jintLong arg0, jintArray arg1)
-{
- jint *lparg1=NULL;
- jboolean rc = 0;
- OS_NATIVE_ENTER(env, that, g_1main_1context_1prepare_FUNC);
- if (arg1) if ((lparg1 = (*env)->GetIntArrayElements(env, arg1, NULL)) == NULL) goto fail;
- rc = (jboolean)g_main_context_prepare((GMainContext *)arg0, lparg1);
-fail:
- if (arg1 && lparg1) (*env)->ReleaseIntArrayElements(env, arg1, lparg1, 0);
- OS_NATIVE_EXIT(env, that, g_1main_1context_1prepare_FUNC);
- return rc;
-}
-#endif
-
-#ifndef NO_g_1main_1context_1query
-JNIEXPORT jint JNICALL OS_NATIVE(g_1main_1context_1query)
- (JNIEnv *env, jclass that, jintLong arg0, jint arg1, jintArray arg2, jintLong arg3, jint arg4)
-{
- jint *lparg2=NULL;
- jint rc = 0;
- OS_NATIVE_ENTER(env, that, g_1main_1context_1query_FUNC);
- if (arg2) if ((lparg2 = (*env)->GetIntArrayElements(env, arg2, NULL)) == NULL) goto fail;
- rc = (jint)g_main_context_query((GMainContext *)arg0, arg1, lparg2, (GPollFD *)arg3, arg4);
-fail:
- if (arg2 && lparg2) (*env)->ReleaseIntArrayElements(env, arg2, lparg2, 0);
- OS_NATIVE_EXIT(env, that, g_1main_1context_1query_FUNC);
- return rc;
-}
-#endif
-
-#ifndef NO_g_1main_1context_1release
-JNIEXPORT void JNICALL OS_NATIVE(g_1main_1context_1release)
- (JNIEnv *env, jclass that, jintLong arg0)
-{
- OS_NATIVE_ENTER(env, that, g_1main_1context_1release_FUNC);
- g_main_context_release((GMainContext *)arg0);
- OS_NATIVE_EXIT(env, that, g_1main_1context_1release_FUNC);
-}
-#endif
-
#ifndef NO_g_1main_1context_1wakeup
JNIEXPORT void JNICALL OS_NATIVE(g_1main_1context_1wakeup)
(JNIEnv *env, jclass that, jintLong arg0)
@@ -18685,6 +18685,16 @@ JNIEXPORT void JNICALL OS_NATIVE(gdk_1threads_1leave)
}
#endif
+#ifndef NO_gdk_1threads_1set_1lock_1functions
+JNIEXPORT void JNICALL OS_NATIVE(gdk_1threads_1set_1lock_1functions)
+ (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1)
+{
+ OS_NATIVE_ENTER(env, that, gdk_1threads_1set_1lock_1functions_FUNC);
+ gdk_threads_set_lock_functions(arg0, arg1);
+ OS_NATIVE_EXIT(env, that, gdk_1threads_1set_1lock_1functions_FUNC);
+}
+#endif
+
#ifndef NO_localeconv_1decimal_1point
JNIEXPORT jintLong JNICALL OS_NATIVE(localeconv_1decimal_1point)
(JNIEnv *env, jclass that)
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 c0ebf1bd71..4c5eb863c9 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
@@ -18,8 +18,8 @@
#ifdef NATIVE_STATS
-int OS_nativeFunctionCount = 1389;
-int OS_nativeFunctionCallCount[1389];
+int OS_nativeFunctionCount = 1390;
+int OS_nativeFunctionCallCount[1390];
char * OS_nativeFunctionNames[] = {
#ifndef JNI64
"Call__IIII",
@@ -281,6 +281,15 @@ char * OS_nativeFunctionNames[] = {
"_1g_1log_1default_1handler",
"_1g_1log_1remove_1handler",
"_1g_1log_1set_1handler",
+ "_1g_1main_1context_1acquire",
+ "_1g_1main_1context_1check",
+ "_1g_1main_1context_1default",
+ "_1g_1main_1context_1get_1poll_1func",
+ "_1g_1main_1context_1iteration",
+ "_1g_1main_1context_1pending",
+ "_1g_1main_1context_1prepare",
+ "_1g_1main_1context_1query",
+ "_1g_1main_1context_1release",
"_1g_1malloc",
#ifndef JNI64
"_1g_1object_1get__I_3B_3II",
@@ -1480,15 +1489,6 @@ char * OS_nativeFunctionNames[] = {
"_1pango_1tab_1array_1get_1tabs",
"_1pango_1tab_1array_1new",
"_1pango_1tab_1array_1set_1tab",
- "g_1main_1context_1acquire",
- "g_1main_1context_1check",
- "g_1main_1context_1default",
- "g_1main_1context_1get_1poll_1func",
- "g_1main_1context_1iteration",
- "g_1main_1context_1pending",
- "g_1main_1context_1prepare",
- "g_1main_1context_1query",
- "g_1main_1context_1release",
"g_1main_1context_1wakeup",
"g_1value_1get_1double",
"g_1value_1get_1float",
@@ -1503,6 +1503,7 @@ char * OS_nativeFunctionNames[] = {
"gdk_1threads_1enter",
"gdk_1threads_1init",
"gdk_1threads_1leave",
+ "gdk_1threads_1set_1lock_1functions",
"localeconv_1decimal_1point",
#ifndef JNI64
"memmove__ILorg_eclipse_swt_internal_gtk_GInterfaceInfo_2I",
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 aa5dd9be37..07a4b8ca55 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
@@ -289,6 +289,15 @@ typedef enum {
_1g_1log_1default_1handler_FUNC,
_1g_1log_1remove_1handler_FUNC,
_1g_1log_1set_1handler_FUNC,
+ _1g_1main_1context_1acquire_FUNC,
+ _1g_1main_1context_1check_FUNC,
+ _1g_1main_1context_1default_FUNC,
+ _1g_1main_1context_1get_1poll_1func_FUNC,
+ _1g_1main_1context_1iteration_FUNC,
+ _1g_1main_1context_1pending_FUNC,
+ _1g_1main_1context_1prepare_FUNC,
+ _1g_1main_1context_1query_FUNC,
+ _1g_1main_1context_1release_FUNC,
_1g_1malloc_FUNC,
#ifndef JNI64
_1g_1object_1get__I_3B_3II_FUNC,
@@ -1488,15 +1497,6 @@ typedef enum {
_1pango_1tab_1array_1get_1tabs_FUNC,
_1pango_1tab_1array_1new_FUNC,
_1pango_1tab_1array_1set_1tab_FUNC,
- g_1main_1context_1acquire_FUNC,
- g_1main_1context_1check_FUNC,
- g_1main_1context_1default_FUNC,
- g_1main_1context_1get_1poll_1func_FUNC,
- g_1main_1context_1iteration_FUNC,
- g_1main_1context_1pending_FUNC,
- g_1main_1context_1prepare_FUNC,
- g_1main_1context_1query_FUNC,
- g_1main_1context_1release_FUNC,
g_1main_1context_1wakeup_FUNC,
g_1value_1get_1double_FUNC,
g_1value_1get_1float_FUNC,
@@ -1511,6 +1511,7 @@ typedef enum {
gdk_1threads_1enter_FUNC,
gdk_1threads_1init_FUNC,
gdk_1threads_1leave_FUNC,
+ gdk_1threads_1set_1lock_1functions_FUNC,
localeconv_1decimal_1point_FUNC,
#ifndef JNI64
memmove__ILorg_eclipse_swt_internal_gtk_GInterfaceInfo_2I_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/Lock.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/Lock.java
index 2aa40155ac..7254f5266a 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/Lock.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/Lock.java
@@ -10,14 +10,13 @@
*******************************************************************************/
package org.eclipse.swt.internal;
-import org.eclipse.swt.internal.gtk.OS;
-
/**
* Instances of this represent a recursive monitor.
*/
public class Lock {
- public static Thread uiThread;
-
+ int count, waitCount;
+ Thread owner;
+
/**
* Locks the monitor and returns the lock count. If
* the lock is owned by another thread, wait until
@@ -26,8 +25,22 @@ public class Lock {
* @return the lock count
*/
public int lock() {
- if (Thread.currentThread() != uiThread) OS.gdk_threads_enter();
- return 1;
+ synchronized (this) {
+ Thread current = Thread.currentThread();
+ if (owner != current) {
+ waitCount++;
+ while (count > 0) {
+ try {
+ wait();
+ } catch (InterruptedException e) {
+ /* Wait forever, just like synchronized blocks */
+ }
+ }
+ --waitCount;
+ owner = current;
+ }
+ return ++count;
+ }
}
/**
@@ -35,6 +48,14 @@ public int lock() {
* the monitor owner, do nothing.
*/
public void unlock() {
- if (Thread.currentThread() != uiThread) OS.gdk_threads_leave();
+ synchronized (this) {
+ Thread current = Thread.currentThread();
+ if (owner == current) {
+ if (--count == 0) {
+ owner = null;
+ if (waitCount > 0) notifyAll();
+ }
+ }
+ }
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
index 53070ab2d0..ac1df1a8e3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
@@ -2219,28 +2219,100 @@ public static final void g_closure_unref(int /*long*/ closure) {
}
}
/** @param context cast=(GMainContext *) */
-public static final native boolean g_main_context_acquire(int /*long*/ context);
+public static final native boolean _g_main_context_acquire(int /*long*/ context);
+public static final boolean g_main_context_acquire(int /*long*/ context) {
+ lock.lock();
+ try {
+ return _g_main_context_acquire(context);
+ } finally {
+ lock.unlock();
+ }
+}
/**
* @param context cast=(GMainContext *)
* @param fds cast=(GPollFD *)
*/
-public static final native int g_main_context_check(int /*long*/ context, int max_priority, int /*long*/ fds, int n_fds);
-public static final native int /*long*/ g_main_context_default();
+public static final native int _g_main_context_check(int /*long*/ context, int max_priority, int /*long*/ fds, int n_fds);
+public static final int g_main_context_check(int /*long*/ context, int max_priority, int /*long*/ fds, int n_fds) {
+ lock.lock();
+ try {
+ return _g_main_context_check(context, max_priority, fds, n_fds);
+ } finally {
+ lock.unlock();
+ }
+}
+public static final native int /*long*/ _g_main_context_default();
+public static final int /*long*/ g_main_context_default() {
+ lock.lock();
+ try {
+ return _g_main_context_default();
+ } finally {
+ lock.unlock();
+ }
+}
/** @param context cast=(GMainContext *) */
-public static final native boolean g_main_context_iteration(int /*long*/ context, boolean may_block);
+public static final native boolean _g_main_context_iteration(int /*long*/ context, boolean may_block);
+public static final boolean g_main_context_iteration(int /*long*/ context, boolean may_block) {
+ lock.lock();
+ try {
+ return _g_main_context_iteration(context, may_block);
+ } finally {
+ lock.unlock();
+ }
+}
/** @param context cast=(GMainContext *) */
-public static final native boolean g_main_context_pending(int /*long*/ context);
+public static final native boolean _g_main_context_pending(int /*long*/ context);
+public static final boolean g_main_context_pending(int /*long*/ context) {
+ lock.lock();
+ try {
+ return _g_main_context_pending(context);
+ } finally {
+ lock.unlock();
+ }
+}
/** @param context cast=(GMainContext *) */
-public static final native int /*long*/ g_main_context_get_poll_func(int /*long*/ context);
+public static final native int /*long*/ _g_main_context_get_poll_func(int /*long*/ context);
+public static final int /*long*/ g_main_context_get_poll_func(int /*long*/ context) {
+ lock.lock();
+ try {
+ return _g_main_context_get_poll_func(context);
+ } finally {
+ lock.unlock();
+ }
+}
/** @param context cast=(GMainContext *) */
-public static final native boolean g_main_context_prepare(int /*long*/ context, int[] priority);
+public static final native boolean _g_main_context_prepare(int /*long*/ context, int[] priority);
+public static final boolean g_main_context_prepare(int /*long*/ context, int[] priority) {
+ lock.lock();
+ try {
+ return _g_main_context_prepare(context, priority);
+ } finally {
+ lock.unlock();
+ }
+}
/**
* @param context cast=(GMainContext *)
* @param fds cast=(GPollFD *)
*/
-public static final native int g_main_context_query(int /*long*/ context, int max_priority, int[] timeout_, int /*long*/ fds, int n_fds);
+public static final native int _g_main_context_query(int /*long*/ context, int max_priority, int[] timeout_, int /*long*/ fds, int n_fds);
+public static final int g_main_context_query(int /*long*/ context, int max_priority, int[] timeout_, int /*long*/ fds, int n_fds) {
+ lock.lock();
+ try {
+ return _g_main_context_query(context, max_priority, timeout_, fds, n_fds);
+ } finally {
+ lock.unlock();
+ }
+}
/** @param context cast=(GMainContext *) */
-public static final native void g_main_context_release(int /*long*/ context);
+public static final native void _g_main_context_release(int /*long*/ context);
+public static final void g_main_context_release(int /*long*/ context) {
+ lock.lock();
+ try {
+ _g_main_context_release(context);
+ } finally {
+ lock.unlock();
+ }
+}
/** @param context cast=(GMainContext *) */
public static final native void g_main_context_wakeup(int /*long*/ context);
/**
@@ -5064,6 +5136,7 @@ public static final int gdk_text_property_to_utf8_list (int /*long*/ encoding,
public static final native void gdk_threads_init ();
public static final native void gdk_threads_enter ();
public static final native void gdk_threads_leave ();
+public static final native void gdk_threads_set_lock_functions(int /*long*/ enter_fn, int /*long*/ leave_fn);
/**
* @method flags=dynamic
* @param display cast=(GdkDisplay*)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/PrintDialog.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/PrintDialog.java
index 6b2a034bb8..69098c0dc0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/PrintDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/PrintDialog.java
@@ -398,6 +398,13 @@ public PrinterData open() {
display.setData (SET_MODAL_DIALOG, this);
}
int response = OS.gtk_dialog_run (handle);
+ /*
+ * This call to gdk_threads_leave() is a temporary work around
+ * to avoid deadlocks when gdk_threads_init() is called by native
+ * code outside of SWT (i.e AWT, etc). It ensures that the current
+ * thread leaves the GTK lock acquired by the function above.
+ */
+ OS.gdk_threads_leave();
if (OS.gtk_window_get_modal (handle)) {
display.setData (SET_MODAL_DIALOG, oldModal);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/Printer.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/Printer.java
index a42fab4bdf..2e31cb3de2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/Printer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/Printer.java
@@ -89,6 +89,13 @@ public static PrinterData[] getPrinterList() {
int /*long*/ GtkPrinterFunc_List = printerCallback.getAddress();
if (GtkPrinterFunc_List == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
OS.gtk_enumerate_printers(GtkPrinterFunc_List, 0, 0, true);
+ /*
+ * This call to gdk_threads_leave() is a temporary work around
+ * to avoid deadlocks when gdk_threads_init() is called by native
+ * code outside of SWT (i.e AWT, etc). It ensures that the current
+ * thread leaves the GTK lock acquired by the function above.
+ */
+ OS.gdk_threads_leave();
printerCallback.dispose ();
return printerList;
}
@@ -136,6 +143,13 @@ public static PrinterData getDefaultPrinterData() {
int /*long*/ GtkPrinterFunc_Default = printerCallback.getAddress();
if (GtkPrinterFunc_Default == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
OS.gtk_enumerate_printers(GtkPrinterFunc_Default, 0, 0, true);
+ /*
+ * This call to gdk_threads_leave() is a temporary work around
+ * to avoid deadlocks when gdk_threads_init() is called by native
+ * code outside of SWT (i.e AWT, etc). It ensures that the current
+ * thread leaves the GTK lock acquired by the function above.
+ */
+ OS.gdk_threads_leave();
printerCallback.dispose ();
return printerList[0];
}
@@ -156,6 +170,13 @@ int /*long*/ gtkPrinterFromPrinterData() {
if (GtkPrinterFunc_FindNamedPrinter == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
printer = 0;
OS.gtk_enumerate_printers(GtkPrinterFunc_FindNamedPrinter, 0, 0, true);
+ /*
+ * This call to gdk_threads_leave() is a temporary work around
+ * to avoid deadlocks when gdk_threads_init() is called by native
+ * code outside of SWT (i.e AWT, etc). It ensures that the current
+ * thread leaves the GTK lock acquired by the function above.
+ */
+ OS.gdk_threads_leave();
printerCallback.dispose ();
return printer;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java
index 5bd447c992..a345c35c88 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java
@@ -1662,50 +1662,44 @@ int /*long*/ webkit_status_bar_text_changed (int /*long*/ web_view, int /*long*/
}
int /*long*/ webkit_web_view_ready (int /*long*/ web_view) {
- /* TEMPORARY CODE */
- OS.gdk_threads_enter();
- try {
- WindowEvent newEvent = new WindowEvent (browser);
- newEvent.display = browser.getDisplay ();
- newEvent.widget = browser;
-
- int /*long*/ settings = WebKitGTK.webkit_web_view_get_window_features (webView);
- int[] result = new int[1];
- OS.g_object_get (settings, WebKitGTK.locationbar_visible, result, 0);
- newEvent.addressBar = result[0] != 0;
- result[0] = 0;
- OS.g_object_get (settings, WebKitGTK.menubar_visible, result, 0);
- newEvent.menuBar = result[0] != 0;
- result[0] = 0;
- OS.g_object_get (settings, WebKitGTK.statusbar_visible, result, 0);
- newEvent.statusBar = result[0] != 0;
- result[0] = 0;
- OS.g_object_get (settings, WebKitGTK.toolbar_visible, result, 0);
- newEvent.toolBar = result[0] != 0;
- result[0] = 0;
- OS.g_object_get (settings, WebKitGTK.x, result, 0);
- int x = result[0];
- result[0] = 0;
- OS.g_object_get (settings, WebKitGTK.y, result, 0);
- int y = result[0];
- result[0] = 0;
- OS.g_object_get (settings, WebKitGTK.width, result, 0);
- int width = result[0];
- result[0] = 0;
- OS.g_object_get (settings, WebKitGTK.height, result, 0);
- int height = result[0];
- result[0] = 0;
- if (x != -1 && y != -1) {
- newEvent.location = new Point (x,y);
- }
- if (width != -1 && height != -1) {
- newEvent.size = new Point (width,height);
- }
- for (int i = 0; i < visibilityWindowListeners.length; i++) {
- visibilityWindowListeners[i].show (newEvent);
- }
- } finally {
- OS.gdk_threads_leave();
+ WindowEvent newEvent = new WindowEvent (browser);
+ newEvent.display = browser.getDisplay ();
+ newEvent.widget = browser;
+
+ int /*long*/ settings = WebKitGTK.webkit_web_view_get_window_features (webView);
+ int[] result = new int[1];
+ OS.g_object_get (settings, WebKitGTK.locationbar_visible, result, 0);
+ newEvent.addressBar = result[0] != 0;
+ result[0] = 0;
+ OS.g_object_get (settings, WebKitGTK.menubar_visible, result, 0);
+ newEvent.menuBar = result[0] != 0;
+ result[0] = 0;
+ OS.g_object_get (settings, WebKitGTK.statusbar_visible, result, 0);
+ newEvent.statusBar = result[0] != 0;
+ result[0] = 0;
+ OS.g_object_get (settings, WebKitGTK.toolbar_visible, result, 0);
+ newEvent.toolBar = result[0] != 0;
+ result[0] = 0;
+ OS.g_object_get (settings, WebKitGTK.x, result, 0);
+ int x = result[0];
+ result[0] = 0;
+ OS.g_object_get (settings, WebKitGTK.y, result, 0);
+ int y = result[0];
+ result[0] = 0;
+ OS.g_object_get (settings, WebKitGTK.width, result, 0);
+ int width = result[0];
+ result[0] = 0;
+ OS.g_object_get (settings, WebKitGTK.height, result, 0);
+ int height = result[0];
+ result[0] = 0;
+ if (x != -1 && y != -1) {
+ newEvent.location = new Point (x,y);
+ }
+ if (width != -1 && height != -1) {
+ newEvent.size = new Point (width,height);
+ }
+ for (int i = 0; i < visibilityWindowListeners.length; i++) {
+ visibilityWindowListeners[i].show (newEvent);
}
return 0;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ColorDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ColorDialog.java
index 1605c4993f..d0cbfa8971 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ColorDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ColorDialog.java
@@ -153,6 +153,13 @@ public RGB open () {
hookId = OS.g_signal_add_emission_hook (signalId, 0, display.emissionProc, handle, 0);
}
int response = OS.gtk_dialog_run (handle);
+ /*
+ * This call to gdk_threads_leave() is a temporary work around
+ * to avoid deadlocks when gdk_threads_init() is called by native
+ * code outside of SWT (i.e AWT, etc). It ensures that the current
+ * thread leaves the GTK lock acquired by the function above.
+ */
+ OS.gdk_threads_leave();
if ((style & SWT.RIGHT_TO_LEFT) != 0) {
OS.g_signal_remove_emission_hook (signalId, hookId);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DirectoryDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DirectoryDialog.java
index 3e04cf2905..9bf66c7c07 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DirectoryDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DirectoryDialog.java
@@ -189,6 +189,13 @@ String openChooserDialog () {
hookId = OS.g_signal_add_emission_hook (signalId, 0, display.emissionProc, handle, 0);
}
int response = OS.gtk_dialog_run (handle);
+ /*
+ * This call to gdk_threads_leave() is a temporary work around
+ * to avoid deadlocks when gdk_threads_init() is called by native
+ * code outside of SWT (i.e AWT, etc). It ensures that the current
+ * thread leaves the GTK lock acquired by the function above.
+ */
+ OS.gdk_threads_leave();
if ((style & SWT.RIGHT_TO_LEFT) != 0) {
OS.g_signal_remove_emission_hook (signalId, hookId);
}
@@ -277,6 +284,13 @@ String openClassicDialog () {
hookId = OS.g_signal_add_emission_hook (signalId, 0, display.emissionProc, handle, 0);
}
int response = OS.gtk_dialog_run (handle);
+ /*
+ * This call to gdk_threads_leave() is a temporary work around
+ * to avoid deadlocks when gdk_threads_init() is called by native
+ * code outside of SWT (i.e AWT, etc). It ensures that the current
+ * thread leaves the GTK lock acquired by the function above.
+ */
+ OS.gdk_threads_leave();
if ((style & SWT.RIGHT_TO_LEFT) != 0) {
OS.g_signal_remove_emission_hook (signalId, hookId);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
index d7bb05a5e9..d664795238 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
@@ -897,10 +897,7 @@ void createDisplay (DeviceData data) {
/* Required for g_main_context_wakeup */
if (!OS.g_thread_supported ()) {
OS.g_thread_init (0);
- OS.gdk_threads_init();
}
- OS.gdk_threads_enter ();
- Lock.uiThread = Thread.currentThread();
OS.gtk_set_locale();
if (!OS.gtk_init_check (new int /*long*/ [] {0}, null)) {
SWT.error (SWT.ERROR_NO_HANDLES, null, " [gtk_init_check() failed]"); //$NON-NLS-1$
@@ -1136,8 +1133,6 @@ protected void destroy () {
}
void destroyDisplay () {
- Lock.uiThread = null;
- OS.gdk_threads_leave ();
}
int /*long*/ emissionProc (int /*long*/ ihint, int /*long*/ n_param_values, int /*long*/ param_values, int /*long*/ data) {
@@ -2400,18 +2395,13 @@ Widget getWidget (int /*long*/ handle) {
}
int /*long*/ idleProc (int /*long*/ data) {
- try {
- OS.gdk_threads_enter();
- boolean result = runAsyncMessages (false);
- if (!result) {
- synchronized (idleLock) {
- idleHandle = 0;
- }
+ boolean result = runAsyncMessages (false);
+ if (!result) {
+ synchronized (idleLock) {
+ idleHandle = 0;
}
- return result ? 1 : 0;
- } finally {
- OS.gdk_threads_leave();
}
+ return result ? 1 : 0;
}
/**
@@ -2983,14 +2973,9 @@ public Rectangle map (Control from, Control to, int x, int y, int width, int hei
}
int /*long*/ mouseHoverProc (int /*long*/ handle) {
- try {
- OS.gdk_threads_enter();
- Widget widget = getWidget (handle);
- if (widget == null) return 0;
- return widget.hoverProc (handle);
- } finally {
- OS.gdk_threads_leave();
- }
+ Widget widget = getWidget (handle);
+ if (widget == null) return 0;
+ return widget.hoverProc (handle);
}
/**
@@ -3199,12 +3184,7 @@ public boolean readAndDispatch () {
boolean events = false;
events |= runSettings ();
events |= runPopups ();
- try {
- OS.gdk_threads_leave();
- events |= OS.g_main_context_iteration (0, false);
- } finally {
- OS.gdk_threads_enter();
- }
+ events |= OS.g_main_context_iteration (0, false);
if (events) {
runDeferredEvents ();
return true;
@@ -4042,7 +4022,6 @@ public boolean sleep () {
int /*long*/ context = OS.g_main_context_default ();
boolean result = false;
do {
- OS.gdk_threads_leave();
if (OS.g_main_context_acquire (context)) {
result = OS.g_main_context_prepare (context, max_priority);
int nfds;
@@ -4061,14 +4040,22 @@ public boolean sleep () {
*/
if (timeout [0] < 0) timeout [0] = 50;
- wake = false;
- OS.Call (poll, fds, nfds, timeout [0]);
+ /* Exit the OS lock to allow other threads to enter GTK */
+ Lock lock = OS.lock;
+ int count = lock.lock ();
+ for (int i = 0; i < count; i++) lock.unlock ();
+ try {
+ wake = false;
+ OS.Call (poll, fds, nfds, timeout [0]);
+ } finally {
+ for (int i = 0; i < count; i++) lock.lock ();
+ lock.unlock ();
+ }
}
}
OS.g_main_context_check (context, max_priority [0], fds, nfds);
OS.g_main_context_release (context);
}
- OS.gdk_threads_enter();
} while (!result && getMessageCount () == 0 && !wake);
wake = false;
return true;
@@ -4138,40 +4125,30 @@ public void timerExec (int milliseconds, Runnable runnable) {
}
int /*long*/ timerProc (int /*long*/ i) {
- try {
- OS.gdk_threads_enter();
- if (timerList == null) return 0;
- int index = (int)/*64*/i;
- if (0 <= index && index < timerList.length) {
- Runnable runnable = timerList [index];
- timerList [index] = null;
- timerIds [index] = 0;
- if (runnable != null) runnable.run ();
- }
- return 0;
- } finally {
- OS.gdk_threads_leave();
+ if (timerList == null) return 0;
+ int index = (int)/*64*/i;
+ if (0 <= index && index < timerList.length) {
+ Runnable runnable = timerList [index];
+ timerList [index] = null;
+ timerIds [index] = 0;
+ if (runnable != null) runnable.run ();
}
+ return 0;
}
int /*long*/ caretProc (int /*long*/ clientData) {
- try {
- OS.gdk_threads_enter();
- caretId = 0;
- if (currentCaret == null) {
- return 0;
- }
- if (currentCaret.blinkCaret()) {
- int blinkRate = currentCaret.blinkRate;
- if (blinkRate == 0) return 0;
- caretId = OS.gtk_timeout_add (blinkRate, caretProc, 0);
- } else {
- currentCaret = null;
- }
+ caretId = 0;
+ if (currentCaret == null) {
return 0;
- } finally {
- OS.gdk_threads_leave();
}
+ if (currentCaret.blinkCaret()) {
+ int blinkRate = currentCaret.blinkRate;
+ if (blinkRate == 0) return 0;
+ caretId = OS.gtk_timeout_add (blinkRate, caretProc, 0);
+ } else {
+ currentCaret = null;
+ }
+ return 0;
}
int /*long*/ sizeAllocateProc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ user_data) {
@@ -4424,14 +4401,9 @@ int /*long*/ windowProc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ ar
}
int /*long*/ windowTimerProc (int /*long*/ handle) {
- try {
- OS.gdk_threads_enter();
- Widget widget = getWidget (handle);
- if (widget == null) return 0;
- return widget.timerProc (handle);
- } finally {
- OS.gdk_threads_leave();
- }
+ Widget widget = getWidget (handle);
+ if (widget == null) return 0;
+ return widget.timerProc (handle);
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java
index 71d3f9ad67..fa535e3bc6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FileDialog.java
@@ -442,6 +442,13 @@ String openChooserDialog () {
hookId = OS.g_signal_add_emission_hook (signalId, 0, display.emissionProc, handle, 0);
}
int response = OS.gtk_dialog_run (handle);
+ /*
+ * This call to gdk_threads_leave() is a temporary work around
+ * to avoid deadlocks when gdk_threads_init() is called by native
+ * code outside of SWT (i.e AWT, etc). It ensures that the current
+ * thread leaves the GTK lock acquired by the function above.
+ */
+ OS.gdk_threads_leave();
if ((style & SWT.RIGHT_TO_LEFT) != 0) {
OS.g_signal_remove_emission_hook (signalId, hookId);
}
@@ -484,6 +491,13 @@ String openClassicDialog () {
hookId = OS.g_signal_add_emission_hook (signalId, 0, display.emissionProc, handle, 0);
}
int response = OS.gtk_dialog_run (handle);
+ /*
+ * This call to gdk_threads_leave() is a temporary work around
+ * to avoid deadlocks when gdk_threads_init() is called by native
+ * code outside of SWT (i.e AWT, etc). It ensures that the current
+ * thread leaves the GTK lock acquired by the function above.
+ */
+ OS.gdk_threads_leave();
if ((style & SWT.RIGHT_TO_LEFT) != 0) {
OS.g_signal_remove_emission_hook (signalId, hookId);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java
index 8ba5db6a21..e3241226be 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/FontDialog.java
@@ -176,6 +176,13 @@ public FontData open () {
hookId = OS.g_signal_add_emission_hook (signalId, 0, display.emissionProc, handle, 0);
}
int response = OS.gtk_dialog_run (handle);
+ /*
+ * This call to gdk_threads_leave() is a temporary work around
+ * to avoid deadlocks when gdk_threads_init() is called by native
+ * code outside of SWT (i.e AWT, etc). It ensures that the current
+ * thread leaves the GTK lock acquired by the function above.
+ */
+ OS.gdk_threads_leave();
if ((style & SWT.RIGHT_TO_LEFT) != 0) {
OS.g_signal_remove_emission_hook (signalId, hookId);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MessageBox.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MessageBox.java
index 2a74df669c..42fd41ed6f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MessageBox.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/MessageBox.java
@@ -188,6 +188,13 @@ public int open () {
hookId = OS.g_signal_add_emission_hook (signalId, 0, display.emissionProc, handle, 0);
}
int response = OS.gtk_dialog_run (handle);
+ /*
+ * This call to gdk_threads_leave() is a temporary work around
+ * to avoid deadlocks when gdk_threads_init() is called by native
+ * code outside of SWT (i.e AWT, etc). It ensures that the current
+ * thread leaves the GTK lock acquired by the function above.
+ */
+ OS.gdk_threads_leave();
if ((style & SWT.RIGHT_TO_LEFT) != 0) {
OS.g_signal_remove_emission_hook (signalId, hookId);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
index 1706f3c874..8ba13784f3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
@@ -2039,12 +2039,7 @@ public void setVisible (boolean visible) {
boolean iconic = false;
Shell shell = parent != null ? parent.getShell() : null;
do {
- try {
- OS.gdk_threads_leave();
- OS.g_main_context_iteration (0, false);
- } finally {
- OS.gdk_threads_enter();
- }
+ OS.g_main_context_iteration (0, false);
if (isDisposed ()) break;
iconic = minimized || (shell != null && shell.minimized);
} while (!mapped && !iconic);
diff --git a/bundles/org.eclipse.swt/tasks/build.xml b/bundles/org.eclipse.swt/tasks/build.xml
index a71b843624..40e6100db5 100644
--- a/bundles/org.eclipse.swt/tasks/build.xml
+++ b/bundles/org.eclipse.swt/tasks/build.xml
@@ -147,7 +147,7 @@
<env key="MOZILLA_LIBS" value="${MOZILLA_SDK}/../lib/libembedstring.a -L${MOZILLA_SDK}/../bin -L${MOZILLA_SDK}/../lib/ -lxpcom -lnspr4 -lplds4 -lplc4"/>
<env key="XULRUNNER_INCLUDES" value="-include ${XULRUNNER_SDK}/include/mozilla-config.h -I${XULRUNNER_SDK}/include"/>
<env key="XULRUNNER_LIBS" value="-L${XULRUNNER_SDK}/lib -lxpcomglue"/>
- <env key="PKG_CONFIG_PATH" value="/bluebird/teamswt/swt-builddir/cairo_1.0.2/linux_x86/lib/pkgconfig"/>
+ <env key="PKG_CONFIG_PATH" value="/usr/lib/pkgconfig:/bluebird/teamswt/swt-builddir/cairo_1.0.2/linux_x86/lib/pkgconfig"/>
<arg line="${targets}"/>
<arg line="${clean}"/>
</exec>

Back to the top