diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2015-12-21 18:17:36 +0900 |
---|---|---|
committer | Kohei Yoshida <libreoffice@kohei.us> | 2015-12-23 00:43:31 +0000 |
commit | 8d94017289885efe6c128849e0739b81173289db (patch) | |
tree | 6ff994f51d2afe1536da40d81a1b225a314c8a5a /starmath | |
parent | 4753d78cf93bad974f062d8cfe75b4b610385b7e (diff) |
starmath: Manage SmEditAccessible's pTextHelper via std::unique_ptr
Change-Id: Iefd4314823efec28a8497b5a993fdd01ed12811e
Reviewed-on: https://gerrit.libreoffice.org/20849
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Kohei Yoshida <libreoffice@kohei.us>
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/source/accessibility.cxx | 13 | ||||
-rw-r--r-- | starmath/source/accessibility.hxx | 5 |
2 files changed, 12 insertions, 6 deletions
diff --git a/starmath/source/accessibility.cxx b/starmath/source/accessibility.cxx index 2e81b188d5e7..d5e8217d61d4 100644 --- a/starmath/source/accessibility.cxx +++ b/starmath/source/accessibility.cxx @@ -1601,7 +1601,7 @@ bool SmEditViewForwarder::Paste() SmEditAccessible::SmEditAccessible( SmEditWindow *pEditWin ) : aAccName (SM_RESSTR(STR_CMDBOXWINDOW)), - pTextHelper (nullptr), + pTextHelper (), pWin (pEditWin) { OSL_ENSURE( pWin, "SmEditAccessible: window missing" ); @@ -1609,7 +1609,11 @@ SmEditAccessible::SmEditAccessible( SmEditWindow *pEditWin ) : SmEditAccessible::~SmEditAccessible() { - delete pTextHelper; +} + +::accessibility::AccessibleTextHelper *SmEditAccessible::GetTextHelper() +{ + return pTextHelper.get(); } void SmEditAccessible::Init() @@ -1623,7 +1627,8 @@ void SmEditAccessible::Init() { ::std::unique_ptr< SvxEditSource > pEditSource( new SmEditSource( pWin, *this ) ); - pTextHelper = new ::accessibility::AccessibleTextHelper( std::move(pEditSource) ); + assert(!pTextHelper); + pTextHelper.reset(new ::accessibility::AccessibleTextHelper( std::move(pEditSource) )); pTextHelper->SetEventSource( this ); } } @@ -1644,7 +1649,7 @@ void SmEditAccessible::ClearWin() //! make TextHelper release references //! (e.g. the one set by the 'SetEventSource' call) pTextHelper->Dispose(); - delete pTextHelper; pTextHelper = nullptr; + pTextHelper.reset(); } // XAccessible diff --git a/starmath/source/accessibility.hxx b/starmath/source/accessibility.hxx index c4cd3c32177b..953e44790e50 100644 --- a/starmath/source/accessibility.hxx +++ b/starmath/source/accessibility.hxx @@ -37,6 +37,7 @@ #include <editeng/unoedsrc.hxx> #include <svx/AccessibleTextHelper.hxx> #include <edit.hxx> +#include <memory> class SmGraphicWindow; class SmEditWindow; @@ -314,7 +315,7 @@ class SmEditAccessible : public SmEditAccessibleBaseClass { OUString aAccName; - ::accessibility::AccessibleTextHelper *pTextHelper; + std::unique_ptr<::accessibility::AccessibleTextHelper> pTextHelper; VclPtr<SmEditWindow> pWin; SmEditAccessible( const SmEditAccessible & ) = delete; @@ -324,7 +325,7 @@ public: explicit SmEditAccessible( SmEditWindow *pEditWin ); virtual ~SmEditAccessible(); - ::accessibility::AccessibleTextHelper * GetTextHelper() { return pTextHelper; } + ::accessibility::AccessibleTextHelper * GetTextHelper(); void Init(); void ClearWin(); // to be called when view is destroyed |