[Libreoffice-commits] core.git: starmath/source

Takeshi Abe tabe at fixedpoint.jp
Sat Nov 15 10:03:02 PST 2014


 starmath/source/edit.cxx |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

New commits:
commit 2492783bd87d534e4eb1d6a00f082772e7b03172
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Sun Nov 16 03:00:35 2014 +0900

    Avoid possible memory leaks in case of exceptions
    
    Change-Id: I06525aa32bc17464291126ed676809e23e4227b1

diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx
index 672a775..681789b 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;
     }
 }


More information about the Libreoffice-commits mailing list