diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2014-05-18 23:09:36 +0900 |
---|---|---|
committer | Takeshi Abe <tabe@fixedpoint.jp> | 2014-05-18 23:11:14 +0900 |
commit | c623612b0bd0bbd2307a19ccf3c2f1f343b932b3 (patch) | |
tree | d6acdc5fbb73c0bbee22ed3f995d8fb17dba9d33 /sc/source/ui/miscdlgs/scuiautofmt.cxx | |
parent | 558618e0dd75424bd2d7134ba536ee78bdb4a26a (diff) |
Avoid possible memory leaks in case of exceptions
Change-Id: Icc1e11e173329fd88898a3d13270406fd651eb2b
Diffstat (limited to 'sc/source/ui/miscdlgs/scuiautofmt.cxx')
-rw-r--r-- | sc/source/ui/miscdlgs/scuiautofmt.cxx | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/sc/source/ui/miscdlgs/scuiautofmt.cxx b/sc/source/ui/miscdlgs/scuiautofmt.cxx index 8618f7aac695..1b7f9f3db5b6 100644 --- a/sc/source/ui/miscdlgs/scuiautofmt.cxx +++ b/sc/source/ui/miscdlgs/scuiautofmt.cxx @@ -50,6 +50,7 @@ #include "scuiautofmt.hxx" #include "scresid.hxx" #include "document.hxx" +#include <boost/scoped_ptr.hpp> // AutoFormat-Dialog: @@ -203,16 +204,15 @@ IMPL_LINK_NOARG(ScAutoFormatDlg, AddHdl) { OUString aStrStandard( SfxResId(STR_STANDARD) ); OUString aFormatName; - ScStringInputDlg* pDlg; bool bOk = false; while ( !bOk ) { - pDlg = new ScStringInputDlg( this, + boost::scoped_ptr<ScStringInputDlg> pDlg(new ScStringInputDlg( this, aStrTitle, aStrLabel, aFormatName, - HID_SC_ADD_AUTOFMT, HID_SC_AUTOFMT_NAME ); + HID_SC_ADD_AUTOFMT, HID_SC_AUTOFMT_NAME )); if ( pDlg->Execute() == RET_OK ) { @@ -261,8 +261,6 @@ IMPL_LINK_NOARG(ScAutoFormatDlg, AddHdl) } else bOk = true; - - delete pDlg; } } @@ -316,11 +314,11 @@ IMPL_LINK_NOARG(ScAutoFormatDlg, RenameHdl) OUString aFormatName = m_pLbFormat->GetSelectEntry(); OUString aEntry; - ScStringInputDlg* pDlg = new ScStringInputDlg( this, + boost::scoped_ptr<ScStringInputDlg> pDlg(new ScStringInputDlg( this, aStrRename, aStrLabel, aFormatName, - HID_SC_REN_AFMT_DLG, HID_SC_REN_AFMT_NAME ); + HID_SC_REN_AFMT_DLG, HID_SC_REN_AFMT_NAME )); if( pDlg->Execute() == RET_OK ) { bool bFmtRenamed = false; @@ -386,7 +384,6 @@ IMPL_LINK_NOARG(ScAutoFormatDlg, RenameHdl) } else bOk = true; - delete pDlg; } return 0; |