summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrant Gayed <ggayed>2009-12-09 20:06:06 +0000
committerGrant Gayed <ggayed>2009-12-09 20:06:06 +0000
commitc2b2ab294da43e2ebd7d4c764a04c9d5b7d5ca74 (patch)
tree4457cab5c5ef3783c9fd75482bf46aa3cfee1a3f
parent08e03e26ecf481fdcc46d4e7edbaee372d51dde2 (diff)
downloadeclipse.platform.swt-c2b2ab294da43e2ebd7d4c764a04c9d5b7d5ca74.tar.gz
eclipse.platform.swt-c2b2ab294da43e2ebd7d4c764a04c9d5b7d5ca74.tar.xz
eclipse.platform.swt-c2b2ab294da43e2ebd7d4c764a04c9d5b7d5ca74.zip
295185 - Refresh of PDF in SWT browser leads to jvm crash
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java52
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/Clipboard.java4
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java4
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DropTarget.java8
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/OleEnumFORMATETC.java4
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleClientSite.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFrame.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/COM.java2
8 files changed, 75 insertions, 9 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java
index 19ebdb16b3..fd3c147205 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/IE.java
@@ -38,6 +38,7 @@ class IE extends WebBrowser {
static int IEVersion;
static String ProgId = "Shell.Explorer"; //$NON-NLS-1$
+ static int PDFCount;
static final int BeforeNavigate2 = 0xfa;
static final int CommandStateChange = 0x69;
@@ -97,6 +98,9 @@ class IE extends WebBrowser {
static final String ABOUT_BLANK = "about:blank"; //$NON-NLS-1$
static final String CLSID_SHELLEXPLORER1 = "{EAB22AC3-30C1-11CF-A7EB-0000C05BAE0B}"; //$NON-NLS-1$
+ static final String EXTENSION_PDF = ".pdf"; //$NON-NLS-1$
+ static final int MAX_PDF = 20;
+
static final String EVENT_DOUBLECLICK = "dblclick"; //$NON-NLS-1$
static final String EVENT_DRAGEND = "dragend"; //$NON-NLS-1$
static final String EVENT_DRAGSTART = "dragstart"; //$NON-NLS-1$
@@ -522,7 +526,30 @@ public void create(Composite parent, int style) {
Variant varResult = event.arguments[0];
IDispatch dispatch = varResult.getDispatch();
if (globalDispatch == 0) globalDispatch = dispatch.getAddress();
-
+
+ /*
+ * Bug in Acrobat Reader on Windows 2000 and XP (works on Vista and
+ * Windows 7). Opening > MAX_PDF PDF files causes Acrobat to not
+ * clean up its shells properly when the container Browser is disposed.
+ * This results in Eclipse crashing at shutdown time because the leftover
+ * shells have invalid references to unloaded Acrobat libraries. The
+ * workaround is to not unload the Acrobat libraries if > MAX_PDF PDF
+ * files have been opened.
+ */
+ String url = event.arguments[1].getString();
+ if (OS.WIN32_VERSION < OS.VERSION (6, 0)) {
+ int extensionIndex = url.lastIndexOf('.');
+ if (extensionIndex != -1) {
+ String extension = url.substring(extensionIndex);
+ if (extension.equalsIgnoreCase(EXTENSION_PDF)) {
+ PDFCount++;
+ if (PDFCount > MAX_PDF) {
+ COM.FreeUnusedLibraries = false;
+ }
+ }
+ }
+ }
+
OleAutomation webBrowser = varResult.getAutomation();
varResult = event.arguments[1];
Variant variant = new Variant(auto);
@@ -891,6 +918,29 @@ public boolean isFocusControl () {
}
public void refresh() {
+ /*
+ * Bug in Acrobat Reader on Windows 2000 and XP (works on Vista and
+ * Windows 7). Opening > MAX_PDF PDF files causes Acrobat to not
+ * clean up its shells properly when the container Browser is disposed.
+ * This results in Eclipse crashing at shutdown time because the leftover
+ * shells have invalid references to unloaded Acrobat libraries. The
+ * workaround is to not unload the Acrobat libraries if > MAX_PDF PDF
+ * files have been opened.
+ */
+ if (OS.WIN32_VERSION < OS.VERSION (6, 0)) {
+ String url = getUrl();
+ int extensionIndex = url.lastIndexOf('.');
+ if (extensionIndex != -1) {
+ String extension = url.substring(extensionIndex);
+ if (extension.equalsIgnoreCase (EXTENSION_PDF)) {
+ PDFCount++;
+ if (PDFCount > MAX_PDF) {
+ COM.FreeUnusedLibraries = false;
+ }
+ }
+ }
+ }
+
int[] rgdispid = auto.getIDsOfNames(new String[] { "Refresh" }); //$NON-NLS-1$
auto.invoke(rgdispid[0]);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/Clipboard.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/Clipboard.java
index 10a3126cef..913d7d839e 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/Clipboard.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/Clipboard.java
@@ -649,7 +649,9 @@ private int Release() {
this.data = new Object[0];
this.transferAgents = new Transfer[0];
disposeCOMInterfaces();
- COM.CoFreeUnusedLibraries();
+ if (COM.FreeUnusedLibraries) {
+ COM.CoFreeUnusedLibraries();
+ }
}
return refCount;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java
index a7f220de1f..4e83e954f1 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java
@@ -655,7 +655,9 @@ private int Release() {
refCount--;
if (refCount == 0) {
disposeCOMInterfaces();
- COM.CoFreeUnusedLibraries();
+ if (COM.FreeUnusedLibraries) {
+ COM.CoFreeUnusedLibraries();
+ }
}
return refCount;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DropTarget.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DropTarget.java
index d8258bd77f..fe7785ec2e 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DropTarget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DropTarget.java
@@ -571,7 +571,9 @@ void onDispose () {
}
iDataObject = null;
- COM.CoFreeUnusedLibraries();
+ if (COM.FreeUnusedLibraries) {
+ COM.CoFreeUnusedLibraries();
+ }
}
int opToOs(int operation) {
@@ -627,7 +629,9 @@ int Release() {
if (refCount == 0) {
disposeCOMInterfaces();
- COM.CoFreeUnusedLibraries();
+ if (COM.FreeUnusedLibraries) {
+ COM.CoFreeUnusedLibraries();
+ }
}
return refCount;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/OleEnumFORMATETC.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/OleEnumFORMATETC.java
index c1c8c1fbd6..bfe4acb3c8 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/OleEnumFORMATETC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/OleEnumFORMATETC.java
@@ -133,7 +133,9 @@ int Release() {
if (refCount == 0) {
disposeCOMInterfaces();
- COM.CoFreeUnusedLibraries();
+ if (COM.FreeUnusedLibraries) {
+ COM.CoFreeUnusedLibraries();
+ }
}
return refCount;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleClientSite.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleClientSite.java
index da449cb608..79070603f2 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleClientSite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleClientSite.java
@@ -1126,8 +1126,10 @@ protected void releaseObjectInterfaces() {
objIUnknown.Release();
}
objIUnknown = null;
-
- COM.CoFreeUnusedLibraries();
+
+ if (COM.FreeUnusedLibraries) {
+ COM.CoFreeUnusedLibraries();
+ }
}
/**
* Saves the document to the specified file and includes OLE specific information if specified.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFrame.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFrame.java
index 2677f94545..9e4a5f43ba 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFrame.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFrame.java
@@ -598,7 +598,9 @@ int Release() {
refCount--;
if (refCount == 0){
disposeCOMInterfaces();
- COM.CoFreeUnusedLibraries();
+ if (COM.FreeUnusedLibraries) {
+ COM.CoFreeUnusedLibraries();
+ }
}
return refCount;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/COM.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/COM.java
index 47e71106c1..216a29dcf2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/COM.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/ole/win32/COM.java
@@ -407,6 +407,8 @@ public class COM extends OS {
public static final short VARIANT_TRUE = -1;
public static final short VARIANT_FALSE = 0;
+ public static boolean FreeUnusedLibraries = true;
+
private static GUID IIDFromString(String lpsz) {
int length = lpsz.length();
char[] buffer = new char[length + 1];