mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-04-24 06:48:24 -05:00
Fix crashes related to PulseWidget()
* Fix crash if widget was deleted during animation * Fix crash if multiple animations were started at the same time
This commit is contained in:
parent
0b2e725471
commit
bdd489aea5
|
|
@ -892,7 +892,16 @@ QMetaObject::Connection PulseWidget(QWidget *widget, QColor startColor,
|
|||
paAnimation->setDuration(1000);
|
||||
|
||||
QMetaObject::Connection con;
|
||||
if (!once) {
|
||||
if (once) {
|
||||
auto widgetPtr = widget;
|
||||
con = QWidget::connect(
|
||||
paAnimation, &QPropertyAnimation::finished,
|
||||
[widgetPtr]() {
|
||||
if (widgetPtr) {
|
||||
widgetPtr->setGraphicsEffect(nullptr);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
con = QWidget::connect(
|
||||
paAnimation, &QPropertyAnimation::finished,
|
||||
[paAnimation]() {
|
||||
|
|
@ -900,10 +909,6 @@ QMetaObject::Connection PulseWidget(QWidget *widget, QColor startColor,
|
|||
paAnimation->start();
|
||||
});
|
||||
});
|
||||
} else {
|
||||
con = QWidget::connect(
|
||||
paAnimation, &QPropertyAnimation::finished,
|
||||
[widget]() { widget->setGraphicsEffect(nullptr); });
|
||||
}
|
||||
|
||||
paAnimation->start();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user