Kaydet (Commit) 576c7562 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Return std::unique_ptr from svt::AcceleratorExecute::createAcceleratorHelper

...to prevent errors like 5ac6e002 "Memory leak"

Change-Id: I3e20393af628849d8a387b491b75e1aacdea982a
üst 1e0e115d
...@@ -1252,7 +1252,7 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) ...@@ -1252,7 +1252,7 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt )
// handle accelerators // handle accelerators
if( ! m_apAccelExecute.get() && m_xFrame.is() && m_xCC.is() ) if( ! m_apAccelExecute.get() && m_xFrame.is() && m_xCC.is() )
{ {
m_apAccelExecute.reset( ::svt::AcceleratorExecute::createAcceleratorHelper()); m_apAccelExecute = ::svt::AcceleratorExecute::createAcceleratorHelper();
OSL_ASSERT( m_apAccelExecute.get()); OSL_ASSERT( m_apAccelExecute.get());
if( m_apAccelExecute.get() ) if( m_apAccelExecute.get() )
m_apAccelExecute->init( m_xCC, m_xFrame ); m_apAccelExecute->init( m_xCC, m_xFrame );
......
...@@ -47,7 +47,7 @@ namespace dbaui ...@@ -47,7 +47,7 @@ namespace dbaui
,m_xController( &_rController ) ,m_xController( &_rController )
,m_aSeparator( VclPtr<FixedLine>::Create(this) ) ,m_aSeparator( VclPtr<FixedLine>::Create(this) )
{ {
m_pAccel.reset(::svt::AcceleratorExecute::createAcceleratorHelper()); m_pAccel = ::svt::AcceleratorExecute::createAcceleratorHelper();
m_aSeparator->Show(); m_aSeparator->Show();
} }
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <svtools/svtdllapi.h> #include <svtools/svtdllapi.h>
#include <memory>
#include <vector> #include <vector>
#include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/uno/XComponentContext.hpp>
...@@ -114,7 +115,7 @@ class SVT_DLLPUBLIC AcceleratorExecute : private TMutexInit ...@@ -114,7 +115,7 @@ class SVT_DLLPUBLIC AcceleratorExecute : private TMutexInit
environment will be recognized ... The helper stop its environment will be recognized ... The helper stop its
work immediately then! work immediately then!
*/ */
static AcceleratorExecute* createAcceleratorHelper(); static std::unique_ptr<AcceleratorExecute> createAcceleratorHelper();
/** @short fight against inlining ... */ /** @short fight against inlining ... */
......
...@@ -442,7 +442,7 @@ bool BackingWindow::PreNotify( NotifyEvent& rNEvt ) ...@@ -442,7 +442,7 @@ bool BackingWindow::PreNotify( NotifyEvent& rNEvt )
// try the 'normal' accelerators (so that eg. Ctrl+Q works) // try the 'normal' accelerators (so that eg. Ctrl+Q works)
if (!mpAccExec) if (!mpAccExec)
{ {
mpAccExec.reset(svt::AcceleratorExecute::createAcceleratorHelper()); mpAccExec = svt::AcceleratorExecute::createAcceleratorHelper();
mpAccExec->init( comphelper::getProcessComponentContext(), mxFrame); mpAccExec->init( comphelper::getProcessComponentContext(), mxFrame);
} }
......
...@@ -1619,8 +1619,7 @@ bool SfxViewShell::ExecKey_Impl(const KeyEvent& aKey) ...@@ -1619,8 +1619,7 @@ bool SfxViewShell::ExecKey_Impl(const KeyEvent& aKey)
{ {
if (!pImp->m_xAccExec.get()) if (!pImp->m_xAccExec.get())
{ {
pImp->m_xAccExec.reset( pImp->m_xAccExec = ::svt::AcceleratorExecute::createAcceleratorHelper();
::svt::AcceleratorExecute::createAcceleratorHelper() );
pImp->m_xAccExec->init(::comphelper::getProcessComponentContext(), pImp->m_xAccExec->init(::comphelper::getProcessComponentContext(),
pFrame->GetFrame().GetFrameInterface()); pFrame->GetFrame().GetFrameInterface());
} }
......
...@@ -93,10 +93,9 @@ AcceleratorExecute::~AcceleratorExecute() ...@@ -93,10 +93,9 @@ AcceleratorExecute::~AcceleratorExecute()
} }
AcceleratorExecute* AcceleratorExecute::createAcceleratorHelper() std::unique_ptr<AcceleratorExecute> AcceleratorExecute::createAcceleratorHelper()
{ {
AcceleratorExecute* pNew = new AcceleratorExecute(); return std::unique_ptr<AcceleratorExecute>(new AcceleratorExecute);
return pNew;
} }
......
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