Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrant Gayed2012-05-15 18:35:00 +0000
committerGrant Gayed2012-05-15 18:35:50 +0000
commit8d895e4bdf05b8234ec4199b4f2b83cc1cbe3aaa (patch)
tree0b462edccd633329b4ab31fea22d81ca2901d05c /bundles/org.eclipse.swt
parent3b7e04304effe884e33175739d7c3054dcac5e13 (diff)
downloadeclipse.platform.swt-8d895e4bdf05b8234ec4199b4f2b83cc1cbe3aaa.tar.gz
eclipse.platform.swt-8d895e4bdf05b8234ec4199b4f2b83cc1cbe3aaa.tar.xz
eclipse.platform.swt-8d895e4bdf05b8234ec4199b4f2b83cc1cbe3aaa.zip
Bug 379446 - FileDialog hangs when choosing download destination with
WebKitGTK 1.8.x
Diffstat (limited to 'bundles/org.eclipse.swt')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java46
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/internal/webkit/WebKitGTK.java33
2 files changed, 64 insertions, 15 deletions
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 5312eadd49..32dc27140d 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
@@ -1603,21 +1603,37 @@ int /*long*/ webkit_download_requested (int /*long*/ web_view, int /*long*/ down
int length = OS.strlen (name);
byte[] bytes = new byte[length];
OS.memmove (bytes, name, length);
- String nameString = new String (Converter.mbcsToWcs (null, bytes));
- FileDialog dialog = new FileDialog (browser.getShell (), SWT.OPEN);
- dialog.setFileName (nameString);
- String title = Compatibility.getMessage ("SWT_FileDownload"); //$NON-NLS-1$
- dialog.setText (title);
- String path = dialog.open ();
-
- if (path != null) {
- path = URI_FILEROOT + path;
- byte[] uriBytes = Converter.wcsToMbcs (null, path, true);
- WebKitGTK.webkit_download_set_destination_uri (download, uriBytes);
- openDownloadWindow (download);
- } else {
- WebKitGTK.webkit_download_cancel (download);
- }
+ final String nameString = new String (Converter.mbcsToWcs (null, bytes));
+
+ final int /*long*/ request = WebKitGTK.webkit_download_get_network_request (download);
+ OS.g_object_ref (request);
+
+ /*
+ * As of WebKitGTK 1.8.x attempting to show a FileDialog in this callback causes
+ * a hang. The workaround is to open it asynchronously with a new download.
+ */
+ browser.getDisplay ().asyncExec (new Runnable () {
+ public void run () {
+ if (!browser.isDisposed ()) {
+ FileDialog dialog = new FileDialog (browser.getShell (), SWT.OPEN);
+ dialog.setFileName (nameString);
+ String title = Compatibility.getMessage ("SWT_FileDownload"); //$NON-NLS-1$
+ dialog.setText (title);
+ String path = dialog.open ();
+ if (path != null) {
+ path = URI_FILEROOT + path;
+ int /*long*/ newDownload = WebKitGTK.webkit_download_new (request);
+ byte[] uriBytes = Converter.wcsToMbcs (null, path, true);
+ WebKitGTK.webkit_download_set_destination_uri (newDownload, uriBytes);
+ openDownloadWindow (newDownload);
+ WebKitGTK.webkit_download_start (newDownload);
+ OS.g_object_unref (newDownload);
+ }
+ }
+ OS.g_object_unref (request);
+ }
+ });
+
return 1;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/internal/webkit/WebKitGTK.java b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/internal/webkit/WebKitGTK.java
index 52ba6975f6..c648f6d859 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/internal/webkit/WebKitGTK.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/internal/webkit/WebKitGTK.java
@@ -743,6 +743,17 @@ public static final long webkit_download_get_current_size (int /*long*/ download
}
/** @method flags=dynamic */
+public static final native int /*long*/ _webkit_download_get_network_request (int /*long*/ download);
+public static final int /*long*/ webkit_download_get_network_request (int /*long*/ download) {
+ lock.lock();
+ try {
+ return _webkit_download_get_network_request (download);
+ } finally {
+ lock.unlock();
+ }
+}
+
+/** @method flags=dynamic */
public static final native int _webkit_download_get_status (int /*long*/ download);
public static final int webkit_download_get_status (int /*long*/ download) {
lock.lock();
@@ -787,6 +798,17 @@ public static final int /*long*/ webkit_download_get_uri (int /*long*/ download)
}
/** @method flags=dynamic */
+public static final native int /*long*/ _webkit_download_new (int /*long*/ request);
+public static final int /*long*/ webkit_download_new (int /*long*/ request) {
+ lock.lock();
+ try {
+ return _webkit_download_new (request);
+ } finally {
+ lock.unlock();
+ }
+}
+
+/** @method flags=dynamic */
public static final native void _webkit_download_set_destination_uri (int /*long*/ download, byte[] destination_uri);
public static final void webkit_download_set_destination_uri (int /*long*/ download, byte[] destination_uri) {
lock.lock();
@@ -798,6 +820,17 @@ public static final void webkit_download_set_destination_uri (int /*long*/ downl
}
/** @method flags=dynamic */
+public static final native void _webkit_download_start (int /*long*/ download);
+public static final void webkit_download_start (int /*long*/ download) {
+ lock.lock();
+ try {
+ _webkit_download_start (download);
+ } finally {
+ lock.unlock();
+ }
+}
+
+/** @method flags=dynamic */
public static final native int /*long*/ _webkit_get_default_session ();
public static final int /*long*/ webkit_get_default_session () {
lock.lock();

Back to the top