我已經編寫了一個IDocHostUIHandler實現,以便爲嵌入式IE11控件提供一個JavaScript對象。一類提供IUnknown,IDispatch和IDocHostUIHandler的實現。 IDispatch接口作爲外部對象返回到GetExternal。 所有調用IDocHostUIHandler除GetExternal調用原始處理程序。mshtml在調用HideUI後失敗並返回FAST_FAIL_INCORRECT_STACK
例如HideUI作爲實現:
HRESULT STDMETHODCALLTYPE mtQtWebBrowserDocHandler::HideUI(void)
{
qDebug("Calling HideUI");
if(m_defaultDocHostUIHandler)
{
HRESULT hr = m_defaultDocHostUIHandler->HideUI();
qDebug("Called HideUI");
return hr;
}
return E_NOTIMPL;
}
相同的模式被用於所有的除了GetExternal的其它方法是:
HRESULT STDMETHODCALLTYPE mtQtWebBrowserDocHandler::GetExternal(IDispatch **ppDispatch)
{
qDebug("Calling GetExternal");
*ppDispatch = (IDispatch*)this;
return S_OK;
}
在JavaScript我執行以下:
var r1 = window.external.Test1();
這會導致以下調試輸出尾部:
'2016-10-10 11:09:19' DEBUG Calling GetHostInfo
'2016-10-10 11:09:19' DEBUG Called GetHostInfo
'2016-10-10 11:09:19' DEBUG mtQtWebBrowserDocHandler Release (ref now = 2)
'2016-10-10 11:09:19' DEBUG mtQtWebBrowserDocHandler AddRef (ref now = 3)
'2016-10-10 11:09:19' DEBUG Calling GetHostInfo
'2016-10-10 11:09:19' DEBUG Called GetHostInfo
'2016-10-10 11:09:19' DEBUG mtQtWebBrowserDocHandler Release (ref now = 2)
'2016-10-10 11:09:19' DEBUG Calling GetExternal
'2016-10-10 11:09:21' DEBUG mtQtWebBrowserDocHandler - IDispatch requested
'2016-10-10 11:09:21' DEBUG mtQtWebBrowserDocHandler AddRef (ref now = 3)
'2016-10-10 11:09:21' DEBUG mtQtWebBrowserDocHandler Release (ref now = 2)
'2016-10-10 11:09:21' DEBUG Calling ShowUI
'2016-10-10 11:09:21' DEBUG Called ShowUI
'2016-10-10 11:09:21' DEBUG Calling HideUI
'2016-10-10 11:09:21' DEBUG Called HideUI
HideUI的最終返回引起INT 29h錯誤,並且ecx = FAST_FAIL_INCORRECT_STACK。預期的堆棧爲0x18D9C4,實際堆棧爲0x18D9A4,差異爲0x20。
我完全迷惑。對我的接口的其他調用正常工作,如果我只是從我的HideUI實現返回E_NOTIMPL,它沒有任何區別。什麼可能會失去平衡?
您應該將此標記爲接受的答案。 –