Index: fpdfsdk/javascript/Document.cpp |
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp |
index 4b597ae12763daec4ef99a2a93b996e9062e5219..0b08f66f338a7142a2ec76e187ab0d856a6c5fe5 100644 |
--- a/fpdfsdk/javascript/Document.cpp |
+++ b/fpdfsdk/javascript/Document.cpp |
@@ -1256,7 +1256,8 @@ |
return FALSE; |
} |
- m_Icons.push_back(IconElement(swIconName, static_cast<Icon*>(pEmbedObj))); |
+ m_IconList.push_back(std::unique_ptr<IconElement>( |
+ new IconElement(swIconName, (Icon*)pEmbedObj))); |
return TRUE; |
} |
@@ -1269,7 +1270,7 @@ |
} |
CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
- if (m_Icons.empty()) { |
+ if (m_IconList.empty()) { |
vp.GetJSValue()->SetNull(pRuntime); |
return TRUE; |
} |
@@ -1277,7 +1278,7 @@ |
CJS_Array Icons; |
int i = 0; |
- for (const auto& element : m_Icons) { |
+ for (const auto& pIconElement : m_IconList) { |
v8::Local<v8::Object> pObj = |
pRuntime->NewFxDynamicObj(CJS_Icon::g_nObjDefnID); |
if (pObj.IsEmpty()) |
@@ -1288,12 +1289,12 @@ |
if (!pJS_Icon) |
return FALSE; |
- Icon* pIcon = static_cast<Icon*>(pJS_Icon->GetEmbedObject()); |
+ Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); |
if (!pIcon) |
return FALSE; |
- pIcon->SetStream(element.IconStream->GetStream()); |
- pIcon->SetIconName(element.IconName); |
+ pIcon->SetStream(pIconElement->IconStream->GetStream()); |
+ pIcon->SetIconName(pIconElement->IconName); |
Icons.SetElement(pRuntime, i++, CJS_Value(pRuntime, pJS_Icon)); |
} |
@@ -1310,34 +1311,35 @@ |
return FALSE; |
} |
- if (m_Icons.empty()) |
+ if (m_IconList.empty()) |
return FALSE; |
CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); |
CFX_WideString swIconName = params[0].ToCFXWideString(pRuntime); |
- for (const auto& element : m_Icons) { |
- if (element.IconName != swIconName) |
- continue; |
- |
- v8::Local<v8::Object> pObj = |
- pRuntime->NewFxDynamicObj(CJS_Icon::g_nObjDefnID); |
- if (pObj.IsEmpty()) |
- return FALSE; |
- |
- CJS_Icon* pJS_Icon = |
- static_cast<CJS_Icon*>(pRuntime->GetObjectPrivate(pObj)); |
- if (!pJS_Icon) |
- return FALSE; |
- |
- Icon* pIcon = static_cast<Icon*>(pJS_Icon->GetEmbedObject()); |
- if (!pIcon) |
- return FALSE; |
- |
- pIcon->SetIconName(swIconName); |
- pIcon->SetStream(element.IconStream->GetStream()); |
- vRet = CJS_Value(pRuntime, pJS_Icon); |
- return TRUE; |
+ for (const auto& pIconElement : m_IconList) { |
+ if (pIconElement->IconName == swIconName) { |
+ Icon* pRetIcon = pIconElement->IconStream; |
+ |
+ v8::Local<v8::Object> pObj = |
+ pRuntime->NewFxDynamicObj(CJS_Icon::g_nObjDefnID); |
+ if (pObj.IsEmpty()) |
+ return FALSE; |
+ |
+ CJS_Icon* pJS_Icon = |
+ static_cast<CJS_Icon*>(pRuntime->GetObjectPrivate(pObj)); |
+ if (!pJS_Icon) |
+ return FALSE; |
+ |
+ Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); |
+ if (!pIcon) |
+ return FALSE; |
+ |
+ pIcon->SetIconName(swIconName); |
+ pIcon->SetStream(pRetIcon->GetStream()); |
+ vRet = CJS_Value(pRuntime, pJS_Icon); |
+ return TRUE; |
+ } |
} |
return FALSE; |