Kaydet (Commit) 8d940172 authored tarafından Takeshi Abe's avatar Takeshi Abe Kaydeden (comit) Kohei Yoshida

starmath: Manage SmEditAccessible's pTextHelper via std::unique_ptr

Change-Id: Iefd4314823efec28a8497b5a993fdd01ed12811e
Reviewed-on: https://gerrit.libreoffice.org/20849Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarKohei Yoshida <libreoffice@kohei.us>
üst 4753d78c
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment