2012-12-11 4 views
0

NPAPI 플러그인을 사용하여 Javascript를 통해 속성 값을 가져 오려고 할 때 문제가 있습니다. 디버깅하는 동안 모든 함수 체인 (HasProperty, HasMethod 및 GetProperty)이 호출되는 것을 볼 수 있습니다. GetProperty를 호출하는 동안 결과 매개 변수에 새 값을 설정한다는 것을 알았습니다. 그러나 GetProperty를 떠나면 예외가 발생하고 그 이유를 이해할 수 없습니다.자바 스크립트에서 NPAPI 플러그인의 속성에 액세스합니다.

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; 
} 
+1

없음 코드 샘플, 아니 세부 사항을 어떤 시도되었습니다 ... 아니, 우리가 당신을 도울 수 있다고 생각하지 않습니다. 아마도 좀 더 자세한 정보를 추가했다면? – taxilian

+0

기능 체인을 제공했습니다 – pimanych

답변

1

당신은 NPN_MemAlloc() 사용할 필요가 : 예외의 아무 표시없는 것에

NPUTF8* newValue = NPN_MemAlloc(length + 1); 
+0

ㅎ. 저주받은 저, 저의 친구, 저도 그걸 쓰고있었습니다 .- P 당신은 이번 라운드에서 다시 이깁니다 ... =] – taxilian

+1

@tax : 죄송합니다, 나는 알고 있었을 것입니다 ...;) –

+0

그래, 모두 훌륭합니다. 따라서 브라우저의 힙이 아닌 브라우저에 메모리를 할당하는 것은 해로운 일입니다. – pimanych