Skip to content

Commit b0a1fb7

Browse files
committed
[Win32] Fix faulty HRESULT_FROM_WIN32 comparison in Edge
Edge compares the result of WebView initialization with an HRESULT created from a Windows error code via the HRESULT_FROM_WIN32 macro. The actual result in that initialization callback is a long while the HRESULT returned from the macro is represented as integer in SWT. The current comparison of long and integer does not take into account that the values are signed. In this specific case, the actual HRESULT to compare against is 2147947423 while the HRESULT_FROM_WIN32 macro returns the signed value -2147019873. The actual result needs to be converted into a signed integer as well, as otherwise it will be considered as 2147947423, thus never matching the expected HRESULT value. This change converts the processed result into an integer to correct the comparison.
1 parent 3e45b23 commit b0a1fb7

File tree

1 file changed

+5
-4
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser

1 file changed

+5
-4
lines changed

bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,8 @@ private IUnknown createControllerInitializationCallback(int previousAttempts) {
601601
webViewProvider.abortInitialization();
602602
initializationRollback.run();
603603
};
604-
return newCallback((result, pv) -> {
604+
return newCallback((resultAsLong, pv) -> {
605+
int result = (int) resultAsLong;
605606
if (browser.isDisposed()) {
606607
initializationAbortion.run();
607608
return COM.S_OK;
@@ -611,14 +612,14 @@ private IUnknown createControllerInitializationCallback(int previousAttempts) {
611612
SWT.error(SWT.ERROR_INVALID_ARGUMENT, null,
612613
" Edge instance with same data folder but different environment options already exists");
613614
}
614-
switch ((int) result) {
615+
switch (result) {
615616
case COM.S_OK:
616617
new IUnknown(pv).AddRef();
617-
setupBrowser((int) result, pv);
618+
setupBrowser(result, pv);
618619
break;
619620
case COM.E_WRONG_THREAD:
620621
initializationAbortion.run();
621-
error(SWT.ERROR_THREAD_INVALID_ACCESS, (int) result);
622+
error(SWT.ERROR_THREAD_INVALID_ACCESS, result);
622623
break;
623624
case COM.E_ABORT:
624625
initializationAbortion.run();

0 commit comments

Comments
 (0)