Use wxBasicString instead of BSTR in wxWebViewIE to prevent memory leaks.
This commit is contained in:
parent
9030d9390a
commit
564c0aafa5
@ -231,9 +231,9 @@ wxString wxWebViewIE::GetPageSource() const
|
|||||||
hr = bodyTag->get_parentElement(&htmlTag);
|
hr = bodyTag->get_parentElement(&htmlTag);
|
||||||
if(SUCCEEDED(hr))
|
if(SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
BSTR bstr;
|
wxBasicString bstr;
|
||||||
if ( htmlTag->get_outerHTML(&bstr) == S_OK )
|
if ( htmlTag->get_outerHTML(bstr) == S_OK )
|
||||||
source = wxString(bstr);
|
source = bstr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return source;
|
return source;
|
||||||
@ -576,8 +576,8 @@ wxString wxWebViewIE::GetCurrentTitle() const
|
|||||||
wxString s;
|
wxString s;
|
||||||
if(document)
|
if(document)
|
||||||
{
|
{
|
||||||
BSTR title;
|
wxBasicString title;
|
||||||
if ( document->get_nameProp(&title) == S_OK )
|
if ( document->get_nameProp(title) == S_OK )
|
||||||
s = title;
|
s = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -705,8 +705,8 @@ bool wxWebViewIE::IsEditable() const
|
|||||||
|
|
||||||
if(document)
|
if(document)
|
||||||
{
|
{
|
||||||
BSTR mode;
|
wxBasicString mode;
|
||||||
if ( document->get_designMode(&mode) == S_OK )
|
if ( document->get_designMode(mode) == S_OK )
|
||||||
{
|
{
|
||||||
if ( wxString(mode) == "On" )
|
if ( wxString(mode) == "On" )
|
||||||
return true;
|
return true;
|
||||||
@ -731,9 +731,9 @@ bool wxWebViewIE::HasSelection() const
|
|||||||
HRESULT hr = document->get_selection(&selection);
|
HRESULT hr = document->get_selection(&selection);
|
||||||
if(SUCCEEDED(hr))
|
if(SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
BSTR type;
|
wxBasicString type;
|
||||||
if ( selection->get_type(&type) == S_OK )
|
if ( selection->get_type(type) == S_OK )
|
||||||
sel = wxString(type);
|
sel = type;
|
||||||
}
|
}
|
||||||
return sel != "None";
|
return sel != "None";
|
||||||
}
|
}
|
||||||
@ -767,9 +767,9 @@ wxString wxWebViewIE::GetSelectedText() const
|
|||||||
hr = disrange->QueryInterface(IID_IHTMLTxtRange, (void**)&range);
|
hr = disrange->QueryInterface(IID_IHTMLTxtRange, (void**)&range);
|
||||||
if(SUCCEEDED(hr))
|
if(SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
BSTR text;
|
wxBasicString text;
|
||||||
if ( range->get_text(&text) == S_OK )
|
if ( range->get_text(text) == S_OK )
|
||||||
selected = wxString(text);
|
selected = text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -800,9 +800,9 @@ wxString wxWebViewIE::GetSelectedSource() const
|
|||||||
hr = disrange->QueryInterface(IID_IHTMLTxtRange, (void**)&range);
|
hr = disrange->QueryInterface(IID_IHTMLTxtRange, (void**)&range);
|
||||||
if(SUCCEEDED(hr))
|
if(SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
BSTR text;
|
wxBasicString text;
|
||||||
if ( range->get_htmlText(&text) == S_OK )
|
if ( range->get_htmlText(text) == S_OK )
|
||||||
selected = wxString(text);
|
selected = text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -841,9 +841,9 @@ wxString wxWebViewIE::GetPageText() const
|
|||||||
HRESULT hr = document->get_body(&body);
|
HRESULT hr = document->get_body(&body);
|
||||||
if(SUCCEEDED(hr))
|
if(SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
BSTR out;
|
wxBasicString out;
|
||||||
if ( body->get_innerText(&out) == S_OK )
|
if ( body->get_innerText(out) == S_OK )
|
||||||
text = wxString(out);
|
text = out;
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
@ -950,7 +950,8 @@ wxCOMPtr<IHTMLDocument2> wxWebViewIE::GetDocument() const
|
|||||||
bool wxWebViewIE::IsElementVisible(wxCOMPtr<IHTMLElement> elm)
|
bool wxWebViewIE::IsElementVisible(wxCOMPtr<IHTMLElement> elm)
|
||||||
{
|
{
|
||||||
wxCOMPtr<IHTMLElement> elm1 = elm;
|
wxCOMPtr<IHTMLElement> elm1 = elm;
|
||||||
BSTR tmp_bstr;
|
wxBasicString display_bstr;
|
||||||
|
wxBasicString visibility_bstr;
|
||||||
bool is_visible = true;
|
bool is_visible = true;
|
||||||
//This method is not perfect but it does discover most of the hidden elements.
|
//This method is not perfect but it does discover most of the hidden elements.
|
||||||
//so if a better solution is found, then please do improve.
|
//so if a better solution is found, then please do improve.
|
||||||
@ -963,14 +964,14 @@ bool wxWebViewIE::IsElementVisible(wxCOMPtr<IHTMLElement> elm)
|
|||||||
if(SUCCEEDED(elm2->get_currentStyle(&style)))
|
if(SUCCEEDED(elm2->get_currentStyle(&style)))
|
||||||
{
|
{
|
||||||
//Check if the object has the style display:none.
|
//Check if the object has the style display:none.
|
||||||
if((style->get_display(&tmp_bstr) != S_OK) ||
|
if((style->get_display(display_bstr) != S_OK) ||
|
||||||
(tmp_bstr != NULL && (wxCRT_StricmpW(tmp_bstr, L"none") == 0)))
|
((BSTR)display_bstr != NULL && (wxCRT_StricmpW(display_bstr, L"none") == 0)))
|
||||||
{
|
{
|
||||||
is_visible = false;
|
is_visible = false;
|
||||||
}
|
}
|
||||||
//Check if the object has the style visibility:hidden.
|
//Check if the object has the style visibility:hidden.
|
||||||
if((is_visible && (style->get_visibility(&tmp_bstr) != S_OK)) ||
|
if((is_visible && (style->get_visibility(visibility_bstr) != S_OK)) ||
|
||||||
(tmp_bstr != NULL && wxCRT_StricmpW(tmp_bstr, L"hidden") == 0))
|
((BSTR)visibility_bstr != NULL && wxCRT_StricmpW(visibility_bstr, L"hidden") == 0))
|
||||||
{
|
{
|
||||||
is_visible = false;
|
is_visible = false;
|
||||||
}
|
}
|
||||||
@ -1007,8 +1008,9 @@ void wxWebViewIE::FindInternal(const wxString& text, int flags, int internal_fla
|
|||||||
if(SUCCEEDED(document->QueryInterface(wxIID_IMarkupContainer, (void **)&pIMC)))
|
if(SUCCEEDED(document->QueryInterface(wxIID_IMarkupContainer, (void **)&pIMC)))
|
||||||
{
|
{
|
||||||
wxCOMPtr<wxIMarkupPointer> ptrBegin, ptrEnd;
|
wxCOMPtr<wxIMarkupPointer> ptrBegin, ptrEnd;
|
||||||
BSTR attr_bstr = SysAllocString(L"style=\"background-color:#ffff00\"");
|
wxBasicString attr_bstr(wxString("style=\"background-color:#ffff00\""));
|
||||||
BSTR text_bstr = SysAllocString(text.wc_str());
|
wxBasicString text_bstr(text.wc_str());
|
||||||
|
|
||||||
pIMS->CreateMarkupPointer(&ptrBegin);
|
pIMS->CreateMarkupPointer(&ptrBegin);
|
||||||
pIMS->CreateMarkupPointer(&ptrEnd);
|
pIMS->CreateMarkupPointer(&ptrEnd);
|
||||||
|
|
||||||
@ -1064,9 +1066,6 @@ void wxWebViewIE::FindInternal(const wxString& text, int flags, int internal_fla
|
|||||||
}
|
}
|
||||||
ptrBegin->MoveToPointer(ptrEnd);
|
ptrBegin->MoveToPointer(ptrEnd);
|
||||||
}
|
}
|
||||||
//Clean up.
|
|
||||||
SysFreeString(text_bstr);
|
|
||||||
SysFreeString(attr_bstr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user