Fix for 19925
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 b532d6e..d620be0 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
@@ -169,8 +169,11 @@
 		char[] fileName = (file.getAbsolutePath()+"\0").toCharArray();

 		int result = COM.GetClassFile(fileName, appClsid);

 		if (result != COM.S_OK)

-			OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result);

-		

+			OLE.error(OLE.ERROR_INVALID_CLASSID, result);

+		// associated CLSID may not be installed on this machine

+		if (getProgramID() == null)

+			OLE.error(OLE.ERROR_INVALID_CLASSID, result);

+			

 		// Open a temporary storage object

 		tempStorage = createTempStorage();

 

@@ -187,8 +190,8 @@
 		

 		if (COM.OleRun(objIUnknown.getAddress()) == OLE.S_OK) state = STATE_RUNNING;

 	} catch (SWTException e) {

+		dispose();

 		disposeCOMInterfaces();

-		frame.Release();

 		throw e;

 	}

 }

@@ -236,8 +239,8 @@
 		if (COM.OleRun(objIUnknown.getAddress()) == OLE.S_OK) state = STATE_RUNNING;

 		

 	} catch (SWTException e) {

+		dispose();

 		disposeCOMInterfaces();

-		frame.Release();

 		throw e;

 	}

 }

@@ -350,8 +353,8 @@
 		

 		if (COM.OleRun(objIUnknown.getAddress()) == OLE.S_OK) state = STATE_RUNNING;

 	} catch (SWTException e) {

+		dispose();

 		disposeCOMInterfaces();

-		frame.Release();

 		throw e;

 	}

 }

@@ -766,7 +769,8 @@
 }

 private void onDispose(Event e) {

 	inDispose = true;

-	doVerb(OLE.OLEIVERB_DISCARDUNDOSTATE);

+	if (state != STATE_NONE)

+		doVerb(OLE.OLEIVERB_DISCARDUNDOSTATE);

 	deactivateInPlaceClient();

 	releaseObjectInterfaces(); // Note, must release object interfaces before releasing frame

 	deleteTempStorage();

diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleControlSite.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleControlSite.java
index 76a607f..ea52aa1 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleControlSite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleControlSite.java
@@ -75,68 +75,68 @@
  */

 public OleControlSite(Composite parent, int style, String progId) {

 	super(parent, style);

-

-	createCOMInterfaces();

-

-	// check for licensing

-	appClsid = getClassID(progId);

-	if (appClsid == null) OLE.error(OLE.ERROR_INVALID_CLASSID);

-

-	int licinfo = getLicenseInfo(appClsid);

-	if (licinfo == 0) {

-		

-		// Open a storage object

-		tempStorage = createTempStorage();

-

-		// Create ole object with storage object

-		int[] address = new int[1];

-		int result = COM.OleCreate(appClsid, COM.IIDIUnknown, COM.OLERENDER_DRAW, null, 0, tempStorage.getAddress(), address);

-		if (result != COM.S_OK)

-			OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result);

-

-		objIUnknown = new IUnknown(address[0]);

-		

-	} else {

-		// Prepare the ClassFactory

-		int[] ppvObject = new int[1];

-		try {

-			int result = COM.CoGetClassObject(appClsid, COM.CLSCTX_INPROC_HANDLER | COM.CLSCTX_INPROC_SERVER, 0, COM.IIDIClassFactory2, ppvObject);

-			if (result != COM.S_OK) {

-				OLE.error(OLE.ERROR_CANNOT_ACCESS_CLASSFACTORY, result);

-			}

-			IClassFactory2 classFactory = new IClassFactory2(ppvObject[0]);

-			// Create Com Object

-			ppvObject = new int[1];

-			result = classFactory.CreateInstanceLic(0, 0, COM.IIDIUnknown, licinfo, ppvObject);

-			classFactory.Release();

-			if (result != COM.S_OK)

-				OLE.error(OLE.ERROR_CANNOT_CREATE_LICENSED_OBJECT, result);

-		} finally {

-			COM.SysFreeString(licinfo);

-		}

-		

-		objIUnknown = new IUnknown(ppvObject[0]);

-

-		// Prepare a storage medium

-		ppvObject = new int[1];

-		if (objIUnknown.QueryInterface(COM.IIDIPersistStorage, ppvObject) == COM.S_OK) {

-			IPersistStorage persist = new IPersistStorage(ppvObject[0]);

-			tempStorage = createTempStorage();

-			persist.InitNew(tempStorage.getAddress());

-			persist.Release();

-		}

-	}

-

-	// Init sinks

 	try {

-		addObjectReferences();

-	} catch (SWTError e) {

-		disposeCOMInterfaces();

-		frame.Release();

-		throw e;

-	}

+		createCOMInterfaces();

+	

+		// check for licensing

+		appClsid = getClassID(progId);

+		if (appClsid == null) OLE.error(OLE.ERROR_INVALID_CLASSID);

+	

+		int licinfo = getLicenseInfo(appClsid);

+		if (licinfo == 0) {

 			

-	if (COM.OleRun(objIUnknown.getAddress()) == OLE.S_OK) state= STATE_RUNNING;

+			// Open a storage object

+			tempStorage = createTempStorage();

+	

+			// Create ole object with storage object

+			int[] address = new int[1];

+			int result = COM.OleCreate(appClsid, COM.IIDIUnknown, COM.OLERENDER_DRAW, null, 0, tempStorage.getAddress(), address);

+			if (result != COM.S_OK)

+				OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result);

+	

+			objIUnknown = new IUnknown(address[0]);

+			

+		} else {

+			// Prepare the ClassFactory

+			int[] ppvObject = new int[1];

+			try {

+				int result = COM.CoGetClassObject(appClsid, COM.CLSCTX_INPROC_HANDLER | COM.CLSCTX_INPROC_SERVER, 0, COM.IIDIClassFactory2, ppvObject);

+				if (result != COM.S_OK) {

+					OLE.error(OLE.ERROR_CANNOT_ACCESS_CLASSFACTORY, result);

+				}

+				IClassFactory2 classFactory = new IClassFactory2(ppvObject[0]);

+				// Create Com Object

+				ppvObject = new int[1];

+				result = classFactory.CreateInstanceLic(0, 0, COM.IIDIUnknown, licinfo, ppvObject);

+				classFactory.Release();

+				if (result != COM.S_OK)

+					OLE.error(OLE.ERROR_CANNOT_CREATE_LICENSED_OBJECT, result);

+			} finally {

+				COM.SysFreeString(licinfo);

+			}

+			

+			objIUnknown = new IUnknown(ppvObject[0]);

+	

+			// Prepare a storage medium

+			ppvObject = new int[1];

+			if (objIUnknown.QueryInterface(COM.IIDIPersistStorage, ppvObject) == COM.S_OK) {

+				IPersistStorage persist = new IPersistStorage(ppvObject[0]);

+				tempStorage = createTempStorage();

+				persist.InitNew(tempStorage.getAddress());

+				persist.Release();

+			}

+		}

+	

+		// Init sinks

+		addObjectReferences();

+			

+		if (COM.OleRun(objIUnknown.getAddress()) == OLE.S_OK) state= STATE_RUNNING;

+

+	} catch (SWTError e) {

+		dispose();

+		disposeCOMInterfaces();

+		throw e;

+	}			

 }

 /**	 

  * Adds the listener to receive events.