starmath/inc/document.hxx | 5 +++-- starmath/source/document.cxx | 17 +++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-)
New commits: commit eb65936f1996cc37632f7241cf07fc85ff633049 Author: Takeshi Abe <t...@fixedpoint.jp> Date: Tue Dec 22 12:00:49 2015 +0900 starmath: Manage SmDocShell's pCursor via std::unique_ptr Change-Id: Id9c67638e5c2e535cc06e9566c9a169471f55da8 Reviewed-on: https://gerrit.libreoffice.org/20856 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Kohei Yoshida <libreoff...@kohei.us> diff --git a/starmath/inc/document.hxx b/starmath/inc/document.hxx index 67ef680e..2cda375 100644 --- a/starmath/inc/document.hxx +++ b/starmath/inc/document.hxx @@ -32,6 +32,7 @@ #include <oox/core/filterbase.hxx> #include <oox/mathml/import.hxx> +#include <memory> #include <set> #include "format.hxx" @@ -102,7 +103,7 @@ class SM_DLLPUBLIC SmDocShell : public SfxObjectShell, public SfxListener VclPtr<Printer> pTmpPrinter; //ditto sal_uInt16 nModifyCount; bool bIsFormulaArranged; - SmCursor *pCursor; + std::unique_ptr<SmCursor> pCursor; std::set< OUString > aUsedSymbols; // to export used symbols only when saving @@ -219,7 +220,7 @@ public: /** True, if cursor have previously been requested and thus * has some sort of position. */ - bool HasCursor() { return pCursor != nullptr; } + bool HasCursor(); }; #endif diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx index dae2175..9657bf6 100644 --- a/starmath/source/document.cxx +++ b/starmath/source/document.cxx @@ -489,17 +489,19 @@ Size SmDocShell::GetSize() } void SmDocShell::InvalidateCursor(){ - delete pCursor; - pCursor = nullptr; + pCursor.reset(); } SmCursor& SmDocShell::GetCursor(){ if(!pCursor) - pCursor = new SmCursor(pTree, this); + pCursor.reset(new SmCursor(pTree, this)); return *pCursor; } - +bool SmDocShell::HasCursor() +{ + return pCursor.get() != nullptr; +} SmPrinterAccess::SmPrinterAccess( SmDocShell &rDocShell ) { @@ -656,8 +658,6 @@ SmDocShell::SmDocShell( SfxModelFlags i_nSfxCreationFlags ) , nModifyCount(0) , bIsFormulaArranged(false) { - pCursor = nullptr; - SetPool(&SfxGetpApp()->GetPool()); SmModule *pp = SM_MOD(); @@ -676,10 +676,7 @@ SmDocShell::~SmDocShell() EndListening(aFormat); EndListening(*pp->GetConfig()); - - delete pCursor; - pCursor = nullptr; - + pCursor.reset(); delete pEditEngine; SfxItemPool::Free(pEditEngineItemPool); delete pTree; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits