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(option)) + delete slider; + else if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast(option)) + delete spinbox; + else if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast(option)) + delete groupBox; + else if (const QStyleOptionComboBox *combo = qstyleoption_cast(option)) + delete combo; + else if (const QStyleOptionButton *button = qstyleoption_cast(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(d->animation(styleObject))) {