From 3e7968c2dae5710f0f1efc43193fc985de7e6ba3 Mon Sep 17 00:00:00 2001 From: Steve Lamerton Date: Fri, 1 Jul 2011 10:01:45 +0000 Subject: [PATCH] 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 --- include/wx/msw/webview_ie.h | 7 +++++-- src/msw/webview_ie.cpp | 9 +++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/wx/msw/webview_ie.h b/include/wx/msw/webview_ie.h index 608f4349cf..666e17b32b 100644 --- a/include/wx/msw/webview_ie.h +++ b/include/wx/msw/webview_ie.h @@ -58,7 +58,7 @@ public: const wxString& name = wxWebViewNameStr); virtual void LoadUrl(const wxString& url); - virtual void LoadHistoryItem(wxWebHistoryItem* item); + virtual void LoadHistoryItem(wxSharedPtr 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 > m_historyList; int m_historyPosition; bool m_historyLoadingFromList; diff --git a/src/msw/webview_ie.cpp b/src/msw/webview_ie.cpp index 711932390e..17e6fa308e 100644 --- a/src/msw/webview_ie.cpp +++ b/src/msw/webview_ie.cpp @@ -373,12 +373,13 @@ bool wxWebViewIE::CanGoForward() return false; } -void wxWebViewIE::LoadHistoryItem(wxWebHistoryItem* item) +void wxWebViewIE::LoadHistoryItem(wxSharedPtr 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() -- 2.45.2