NPAPI プラグインを使用して Javascript 経由でプロパティの値を取得しようとすると問題が発生します。デバッグ中に、すべての一連の関数 (HasProperty、HasMethod、および GetProperty) が呼び出されていることがわかります。さらに、GetProperty の呼び出し中に新しい値を結果パラメーターに設定していることがわかります。しかし、GetProperty を離れた後、例外が発生し、その理由がわかりません。
FireFox は、初期化するのを忘れたいくつかの追加関数を呼び出すことができますか?
前もって感謝します
私のコードは次のとおりです。
// static function which calls Get_Property for the instance of CScriptableNPObject
bool CScriptableNPObject::NP_GetProperty(NPObject *npobj, NPIdentifier name, NPVariant *result)
{
m_Logs.WriteLogs(10, _T("Enter the CScriptableNPObject::NP_GetProperty()"));
return ((CScriptableNPObject *)npobj)->GetProperty(name, result);
}
// just converter name from NPIdentifier to char *
bool CScriptableNPObject::GetProperty(NPIdentifier name, NPVariant *result)
{
NPUTF8 *pszProperty = m_pNPNFuncs->utf8fromidentifier(name);
return GetProperty(pszProperty, result);
}
// checking the dictionary of properties, if property exists put its value into the result
bool CScriptableNPObject::GetProperty(NPUTF8 *pszProperty, NPVariant *result)
{
VOID_TO_NPVARIANT(*result);
JSPropertiesMap::iterator it = m_JSProperties.find(pszProperty);
if (it == m_JSProperties.end())
return false;
NPUTF8 *pszNewPropertyValue = new NPUTF8[it->second->value.stringValue.UTF8Length + 1];
sprintf(pszNewPropertyValue, it->second->value.stringValue.UTF8Characters);
STRINGZ_TO_NPVARIANT(pszNewPropertyValue, *result);
return true;
}