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>
This commit is contained in:
parent
7e91b5a2bc
commit
d41fbea2ba
@ -181,6 +181,24 @@ QStyleOption *clonedAnimationStyleOption(const QStyleOption*option) {
|
|||||||
return styleOption;
|
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
|
\class QWindowsVistaStyle
|
||||||
@ -411,7 +429,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
|
|||||||
}
|
}
|
||||||
t->setStartTime(QTime::currentTime());
|
t->setStartTime(QTime::currentTime());
|
||||||
|
|
||||||
delete styleOption;
|
deleteClonedAnimationStyleOption(styleOption);
|
||||||
d->startAnimation(t);
|
d->startAnimation(t);
|
||||||
}
|
}
|
||||||
styleObject->setProperty("_q_no_animation", false);
|
styleObject->setProperty("_q_no_animation", false);
|
||||||
@ -940,7 +958,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
|||||||
t->setStartTime(QTime::currentTime());
|
t->setStartTime(QTime::currentTime());
|
||||||
styleObject->setProperty("_q_no_animation", false);
|
styleObject->setProperty("_q_no_animation", false);
|
||||||
|
|
||||||
delete styleOption;
|
deleteClonedAnimationStyleOption(styleOption);
|
||||||
d->startAnimation(t);
|
d->startAnimation(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1627,7 +1645,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle
|
|||||||
else
|
else
|
||||||
t->setDuration(500);
|
t->setDuration(500);
|
||||||
|
|
||||||
delete styleOption;
|
deleteClonedAnimationStyleOption(styleOption);
|
||||||
d->startAnimation(t);
|
d->startAnimation(t);
|
||||||
}
|
}
|
||||||
if (QWindowsVistaAnimation *anim = qobject_cast<QWindowsVistaAnimation *>(d->animation(styleObject))) {
|
if (QWindowsVistaAnimation *anim = qobject_cast<QWindowsVistaAnimation *>(d->animation(styleObject))) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user