summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-05-06 01:33:30 +0200
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-05-26 00:51:05 +0200
commitada20978a4e5c26dfe6c4227d310a133e50d9b2e (patch)
tree04dd0adc2a7ee55dcd2711e09f5b9c0087d387b5 /sw
parent20c235df449f341774441f3bc5f567b839b75536 (diff)
make SwNavigationMgr use the shared_ptr
- also make it listen to at least one of the SwUnoCrsr it keeps on the heap for document disposing. - as the SwNavigationMgr lives longer than the document this was actually a double free before: first from SwUnoCrsrTbl dtor an then from the shared_ptr in SwNavigationMgr Change-Id: Ia75ad81a978ca37ed2a94fd221427b62e99e1bb3
Diffstat (limited to 'sw')
-rw-r--r--sw/source/uibase/inc/navmgr.hxx9
-rw-r--r--sw/source/uibase/wrtsh/navmgr.cxx21
2 files changed, 22 insertions, 8 deletions
diff --git a/sw/source/uibase/inc/navmgr.hxx b/sw/source/uibase/inc/navmgr.hxx
index 5e33371fb539..ce3128e672b0 100644
--- a/sw/source/uibase/inc/navmgr.hxx
+++ b/sw/source/uibase/inc/navmgr.hxx
@@ -10,16 +10,16 @@
#define INCLUDED_SW_SOURCE_UIBASE_INC_NAVMGR_HXX
#include <vector>
-
-#include <boost/shared_ptr.hpp>
+#include <memory>
#include "swtypes.hxx"
+#include "calbck.hxx"
class SwWrtShell;
struct SwPosition;
class SwUnoCrsr;
-class SwNavigationMgr
+class SwNavigationMgr : SwClient
{
private:
/*
@@ -31,7 +31,7 @@ private:
* (e.g. click a link, or double click an entry from the navigator).
* Every use of the back/forward buttons results in moving the stack pointer within the navigation history
*/
- typedef ::std::vector< ::boost::shared_ptr<SwUnoCrsr> > Stack_t;
+ typedef ::std::vector< std::shared_ptr<SwUnoCrsr> > Stack_t;
Stack_t m_entries;
Stack_t::size_type m_nCurrent; /* Current position within the navigation history */
SwWrtShell & m_rMyShell; /* The active shell within which the navigation occurs */
@@ -51,6 +51,7 @@ public:
void goForward() ;
/* The method that adds the position pPos to the navigation history */
bool addEntry(const SwPosition& rPos);
+ void SwClientNotify(const SwModify& rModify, const SfxHint& rHint) SAL_OVERRIDE;
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/wrtsh/navmgr.cxx b/sw/source/uibase/wrtsh/navmgr.cxx
index 740e8b71e516..d843e3755679 100644
--- a/sw/source/uibase/wrtsh/navmgr.cxx
+++ b/sw/source/uibase/wrtsh/navmgr.cxx
@@ -162,15 +162,17 @@ bool SwNavigationMgr::addEntry(const SwPosition& rPos) {
if (*m_entries.back()->GetPoint() != rPos)
{
- SwUnoCrsr *const pCursor = m_rMyShell.GetDoc()->CreateUnoCrsr(rPos);
- m_entries.push_back(::boost::shared_ptr<SwUnoCrsr>(pCursor));
+ std::shared_ptr<SwUnoCrsr> pCursor(m_rMyShell.GetDoc()->CreateUnoCrsr2(rPos));
+ m_entries.push_back(pCursor);
+ pCursor->Add(this);
}
bRet = true;
}
else {
if ( (!m_entries.empty() && *m_entries.back()->GetPoint() != rPos) || m_entries.empty() ) {
- SwUnoCrsr *const pCursor = m_rMyShell.GetDoc()->CreateUnoCrsr(rPos);
- m_entries.push_back(::boost::shared_ptr<SwUnoCrsr>(pCursor));
+ auto pCursor(m_rMyShell.GetDoc()->CreateUnoCrsr2(rPos));
+ m_entries.push_back(pCursor);
+ pCursor->Add(this);
bRet = true;
}
if (m_entries.size() > 1 && *m_entries.back()->GetPoint() == rPos)
@@ -213,4 +215,15 @@ bool SwNavigationMgr::addEntry(const SwPosition& rPos) {
return bRet;
}
+
+void SwNavigationMgr::SwClientNotify(const SwModify& rModify, const SfxHint& rHint)
+{
+ if(typeid(rHint) == typeid(sw::DocDisposingHint))
+ {
+ m_entries.clear();
+ }
+ else
+ SwClient::SwClientNotify(rModify, rHint);
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */