diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2014-11-16 03:00:35 +0900 |
---|---|---|
committer | Takeshi Abe <tabe@fixedpoint.jp> | 2014-11-16 03:01:26 +0900 |
commit | 2492783bd87d534e4eb1d6a00f082772e7b03172 (patch) | |
tree | d5ff3f08ec484ed1b1512fdfb81b1b6179e4bdf8 /starmath | |
parent | 84a32aae9f08cd88398093b31cc51d7d73d430ac (diff) |
Avoid possible memory leaks in case of exceptions
Change-Id: I06525aa32bc17464291126ed676809e23e4227b1
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/source/edit.cxx | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx index 672a7757eca5..681789b896be 100644 --- a/starmath/source/edit.cxx +++ b/starmath/source/edit.cxx @@ -49,6 +49,7 @@ #include "document.hxx" #include "config.hxx" #include "accessibility.hxx" +#include <boost/scoped_ptr.hpp> #define SCROLL_LINE 24 @@ -336,7 +337,7 @@ void SmEditWindow::Command(const CommandEvent& rCEvt) GetParent()->ToTop(); Point aPoint = rCEvt.GetMousePosPixel(); - PopupMenu* pPopupMenu = new PopupMenu(SmResId(RID_COMMANDMENU)); + boost::scoped_ptr<PopupMenu> pPopupMenu(new PopupMenu(SmResId(RID_COMMANDMENU))); // added for replaceability of context menus Menu* pMenu = NULL; @@ -349,15 +350,13 @@ void SmEditWindow::Command(const CommandEvent& rCEvt) { if ( pMenu ) { - delete pPopupMenu; - pPopupMenu = (PopupMenu*) pMenu; + pPopupMenu.reset((PopupMenu*) pMenu); } } pPopupMenu->SetSelectHdl(LINK(this, SmEditWindow, MenuSelectHdl)); pPopupMenu->Execute( this, aPoint ); - delete pPopupMenu; bForwardEvt = false; } else if (rCEvt.GetCommand() == COMMAND_WHEEL) @@ -1094,13 +1093,12 @@ void SmEditWindow::DeleteEditView( SmViewShell & /*rView*/ ) { if (pEditView) { - EditEngine *pEditEngine = pEditView->GetEditEngine(); + boost::scoped_ptr<EditEngine> pEditEngine(pEditView->GetEditEngine()); if (pEditEngine) { pEditEngine->SetStatusEventHdl( Link() ); pEditEngine->RemoveView( pEditView ); } - delete pEditView; pEditView = 0; } } |