summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJian Liang <jianliang79@gmail.com>2013-01-11 13:50:58 +0800
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-11 21:04:09 +0100
commitd41fbea2ba84959dd860f2a9c651e7eea260b008 (patch)
treeb39bc15d721cc859051c0291cf0822e58d9c27a7 /src
parent7e91b5a2bc51daa888985835fda3f789654afe0b (diff)
Fix memory leak in windows vista style
Introduce a function named deleteClonedAnimationStyleOption() in qwindowsvistastyle.cpp to delete style option cloned by clonedAnimationStyleOption() to prevent object leak which is hold by the actual style option object. Change-Id: I1afd95ddab237059ce3460ac0b52a65de102eaa5 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/styles/qwindowsvistastyle.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp
index 34fddde604..685b328a67 100644
--- a/src/widgets/styles/qwindowsvistastyle.cpp
+++ b/src/widgets/styles/qwindowsvistastyle.cpp
@@ -181,6 +181,24 @@ QStyleOption *clonedAnimationStyleOption(const QStyleOption*option) {
return styleOption;
}
+/* \internal
+ Used by animations to delete cloned styleoption
+*/
+void deleteClonedAnimationStyleOption(const QStyleOption *option)
+{
+ if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider*>(option))
+ delete slider;
+ else if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox*>(option))
+ delete spinbox;
+ else if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox*>(option))
+ delete groupBox;
+ else if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox*>(option))
+ delete combo;
+ else if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton*>(option))
+ delete button;
+ else
+ delete option;
+}
/*!
\class QWindowsVistaStyle
@@ -411,7 +429,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
}
t->setStartTime(QTime::currentTime());
- delete styleOption;
+ deleteClonedAnimationStyleOption(styleOption);
d->startAnimation(t);
}
styleObject->setProperty("_q_no_animation", false);
@@ -940,7 +958,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
t->setStartTime(QTime::currentTime());
styleObject->setProperty("_q_no_animation", false);
- delete styleOption;
+ deleteClonedAnimationStyleOption(styleOption);
d->startAnimation(t);
}
@@ -1627,7 +1645,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle
else
t->setDuration(500);
- delete styleOption;
+ deleteClonedAnimationStyleOption(styleOption);
d->startAnimation(t);
}
if (QWindowsVistaAnimation *anim = qobject_cast<QWindowsVistaAnimation *>(d->animation(styleObject))) {