Use shared pointers throughout when managing history with the ie backend, simplifying memory management. Also add more comments explaining how the history is managed.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/SOC2011_WEBVIEW@68119 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Steve Lamerton
2011-07-01 10:01:45 +00:00
parent 60ec28290b
commit 3e7968c2da
2 changed files with 10 additions and 6 deletions

View File

@@ -58,7 +58,7 @@ public:
const wxString& name = wxWebViewNameStr);
virtual void LoadUrl(const wxString& url);
virtual void LoadHistoryItem(wxWebHistoryItem* item);
virtual void LoadHistoryItem(wxSharedPtr<wxWebHistoryItem> item);
virtual bool CanGoForward();
virtual bool CanGoBack();
@@ -124,7 +124,10 @@ private:
* Busy property is false but should be true.
*/
bool m_isBusy;
//We manage our own history
//We manage our own history, the history list contains the history items
//which are added as documentcomplete events arrive, unless we are loading
//an item from the history. The position is stored as an int, and reflects
//where we are in the history list.
wxVector<wxSharedPtr<wxWebHistoryItem> > m_historyList;
int m_historyPosition;
bool m_historyLoadingFromList;

View File

@@ -373,12 +373,13 @@ bool wxWebViewIE::CanGoForward()
return false;
}
void wxWebViewIE::LoadHistoryItem(wxWebHistoryItem* item)
void wxWebViewIE::LoadHistoryItem(wxSharedPtr<wxWebHistoryItem> item)
{
int pos = -1;
for(unsigned int i = 0; i < m_historyList.size(); i++)
{
if(m_historyList[i].get() == item)
//We compare the actual pointers to find the correct item
if(m_historyList[i].get() == item.get())
pos = i;
}
wxASSERT_MSG(pos != m_historyList.size(), "invalid history item");
@@ -389,12 +390,12 @@ void wxWebViewIE::LoadHistoryItem(wxWebHistoryItem* item)
void wxWebViewIE::GoBack()
{
LoadHistoryItem(m_historyList[m_historyPosition - 1].get());
LoadHistoryItem(m_historyList[m_historyPosition - 1]);
}
void wxWebViewIE::GoForward()
{
LoadHistoryItem(m_historyList[m_historyPosition + 1].get());
LoadHistoryItem(m_historyList[m_historyPosition + 1]);
}
void wxWebViewIE::Stop()