Bug 543747 - [win32] JVM crash after connecting Windows Remote Desktop

Properly save and restore original IMM context, which can be non-zero
in some cases.

Change-Id: Ife51b7c3556252f0f9ca71fa10564e227dab0611
Co-authored-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
Signed-off-by: Nikita Nemkin <nikita@nemkin.ru>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
index f6aa006..40860ca 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
@@ -71,6 +71,7 @@
 	Region region;
 	Font font;
 	int drawCount, foreground, background, backgroundAlpha = 255;
+	long hPrevIMC;
 
 /**
  * Prevents uninitialized instances from being created outside the package.
@@ -724,7 +725,7 @@
 	}
 	if (OS.IsDBLocale && hwndParent != 0) {
 		long hIMC = OS.ImmGetContext (hwndParent);
-		OS.ImmAssociateContext (handle, hIMC);
+		hPrevIMC = OS.ImmAssociateContext (handle, hIMC);
 		OS.ImmReleaseContext (hwndParent, hIMC);
 	}
 
@@ -2541,7 +2542,8 @@
 void releaseWidget () {
 	super.releaseWidget ();
 	if (OS.IsDBLocale) {
-		OS.ImmAssociateContext (handle, 0);
+		OS.ImmAssociateContext (handle, hPrevIMC);
+		hPrevIMC = 0;
 	}
 	if (toolTipText != null) {
 		setToolTipText (getShell (), null);