From c9ae5814eb40acdb683004277573a09c6b78aba9 Mon Sep 17 00:00:00 2001 From: mread Date: Tue, 18 Oct 2011 13:59:51 +0100 Subject: QS60StyleAnimation exception safety QS60StyleAnimation had a number of exception safety problems. - Exceptions from QS60StyleAnimation/V2 could panic a TRAP harness. - Pointers could be uninitialised on exception in constructor. Problems solved by switching to QScopedPointer and simplifying the code. Task-number: QTBUG-4871 incidental finding Reviewed-by: Sami Merila --- src/gui/styles/qs60style_p.h | 4 ++-- src/gui/styles/qs60style_s60.cpp | 10 +++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index 2fa8c7f..ad55761 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -473,8 +473,8 @@ public: private: //data members //TODO: consider changing these to non-pointers as the classes are rather small anyway - AnimationData *m_defaultData; - AnimationDataV2 *m_currentData; + QScopedPointer m_defaultData; + QScopedPointer m_currentData; }; #endif //Q_WS_S60 diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index cfb10fa..eb59115 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -132,14 +132,12 @@ AnimationDataV2::~AnimationDataV2() QS60StyleAnimation::QS60StyleAnimation(const QS60StyleEnums::SkinParts part, int frames, int interval) { - QT_TRAP_THROWING(m_defaultData = new (ELeave) AnimationData(part, frames, interval)); - QT_TRAP_THROWING(m_currentData = new (ELeave) AnimationDataV2(*m_defaultData)); + m_defaultData.reset(new AnimationData(part, frames, interval)); + m_currentData.reset(new AnimationDataV2(*m_defaultData)); } QS60StyleAnimation::~QS60StyleAnimation() { - delete m_currentData; - delete m_defaultData; } void QS60StyleAnimation::setAnimationObject(CAknBitmapAnimation* animation) @@ -152,9 +150,7 @@ void QS60StyleAnimation::setAnimationObject(CAknBitmapAnimation* animation) void QS60StyleAnimation::resetToDefaults() { - delete m_currentData; - m_currentData = 0; - QT_TRAP_THROWING(m_currentData = new (ELeave) AnimationDataV2(*m_defaultData)); + m_currentData.reset(new AnimationDataV2(*m_defaultData)); } class QS60StyleModeSpecifics -- cgit v0.12