summaryrefslogtreecommitdiff
path: root/svtools/source/control/calendar.cxx
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2014-07-04 00:55:08 +0900
committerTakeshi Abe <tabe@fixedpoint.jp>2014-07-04 10:49:10 +0900
commitf38bf4c6c29d685ec4f1015be09f64c7ae2eb172 (patch)
tree84894e4957abbda40a4fa2cc20b200aff3502200 /svtools/source/control/calendar.cxx
parentc061cb94c07dff1d1eac126307e17295460b805b (diff)
Avoid possible memory leaks in case of exceptions
Change-Id: I04a0a2c296206f155ee4916b15b853a7f10c2c2a
Diffstat (limited to 'svtools/source/control/calendar.cxx')
-rw-r--r--svtools/source/control/calendar.cxx39
1 files changed, 13 insertions, 26 deletions
diff --git a/svtools/source/control/calendar.cxx b/svtools/source/control/calendar.cxx
index 26427a42793f..b380baf87e48 100644
--- a/svtools/source/control/calendar.cxx
+++ b/svtools/source/control/calendar.cxx
@@ -37,7 +37,7 @@
#include <svtools/svtools.hrc>
#include <svtools/svtresid.hxx>
#include <svtools/calendar.hxx>
-
+#include <boost/scoped_ptr.hpp>
#define DAY_OFFX 4
@@ -1084,7 +1084,7 @@ void Calendar::ImplUpdateSelection( IntDateSet* pOld )
void Calendar::ImplMouseSelect( const Date& rDate, sal_uInt16 nHitTest,
bool bMove, bool bExpand, bool bExtended )
{
- IntDateSet* pOldSel = new IntDateSet( *mpSelectTable );
+ boost::scoped_ptr<IntDateSet> pOldSel(new IntDateSet( *mpSelectTable ));
Date aOldDate = maCurDate;
Date aTempDate = rDate;
@@ -1181,7 +1181,7 @@ void Calendar::ImplMouseSelect( const Date& rDate, sal_uInt16 nHitTest,
}
HideFocus();
if ( bNewSel )
- ImplUpdateSelection( pOldSel );
+ ImplUpdateSelection( pOldSel.get() );
if ( !bNewSel || pOldSel->find( aOldDate.GetDate() ) == pOldSel->end() )
ImplUpdateDate( aOldDate );
// assure focus rectangle is displayed again
@@ -1189,7 +1189,6 @@ void Calendar::ImplMouseSelect( const Date& rDate, sal_uInt16 nHitTest,
|| mpSelectTable->find( maCurDate.GetDate() ) == mpSelectTable->end() )
ImplUpdateDate( maCurDate );
}
- delete pOldSel;
}
@@ -1355,18 +1354,17 @@ void Calendar::ImplEndTracking( bool bCancel )
if ( !bSpinDown )
{
- IntDateSet* pOldSel = new IntDateSet( *mpSelectTable );
+ boost::scoped_ptr<IntDateSet> pOldSel(new IntDateSet( *mpSelectTable ));
Date aOldDate = maCurDate;
maCurDate = maOldCurDate;
*mpSelectTable = *mpOldSelectTable;
HideFocus();
- ImplUpdateSelection( pOldSel );
+ ImplUpdateSelection( pOldSel.get() );
if ( pOldSel->find( aOldDate.GetDate() ) == pOldSel->end() )
ImplUpdateDate( aOldDate );
// assure focus rectangle is displayed again
if ( HasFocus() || mpSelectTable->find( maCurDate.GetDate() ) == mpSelectTable->end() )
ImplUpdateDate( maCurDate );
- delete pOldSel;
}
}
@@ -1585,7 +1583,7 @@ void Calendar::KeyInput( const KeyEvent& rKEvt )
{
if ( bMultiSel && bExpand )
{
- IntDateSet* pOldSel = new IntDateSet( *mpSelectTable );
+ boost::scoped_ptr<IntDateSet> pOldSel(new IntDateSet( *mpSelectTable ));
Date aOldAnchorDate = maAnchorDate;
mbSelLeft = aNewDate < maAnchorDate;
if ( !bExtended )
@@ -1609,8 +1607,7 @@ void Calendar::KeyInput( const KeyEvent& rKEvt )
mbInSelChange = true;
SelectionChanging();
mbInSelChange = false;
- ImplUpdateSelection( pOldSel );
- delete pOldSel;
+ ImplUpdateSelection( pOldSel.get() );
}
else
{
@@ -1824,40 +1821,30 @@ void Calendar::SelectDate( const Date& rDate, bool bSelect )
if ( !rDate.IsValidAndGregorian() )
return;
- IntDateSet* pOldSel;
+ boost::scoped_ptr<IntDateSet> pOldSel;
if ( !mbInSelChange )
- pOldSel = new IntDateSet( *mpSelectTable );
- else
- pOldSel = NULL;
+ pOldSel.reset(new IntDateSet( *mpSelectTable ));
ImplCalendarSelectDate( mpSelectTable, rDate, bSelect );
if ( pOldSel )
- {
- ImplUpdateSelection( pOldSel );
- delete pOldSel;
- }
+ ImplUpdateSelection( pOldSel.get() );
}
void Calendar::SetNoSelection()
{
- IntDateSet* pOldSel;
+ boost::scoped_ptr<IntDateSet> pOldSel;
if ( !mbInSelChange )
- pOldSel = new IntDateSet( *mpSelectTable );
- else
- pOldSel = NULL;
+ pOldSel.reset(new IntDateSet( *mpSelectTable ));
ImplCalendarClearSelectDate( mpSelectTable );
if ( pOldSel )
- {
- ImplUpdateSelection( pOldSel );
- delete pOldSel;
- }
+ ImplUpdateSelection( pOldSel.get() );
}