on xenial help sign in
Work around AnimatedSprite infinite loop bug

https://bugreports.qt.io/browse/QTBUG-53937 Don't wait until the next event loop iteration before you update the other properties. If you do so, scenegraph thread will sync with an inconsistent state: new image URL + old cursor info. So you would risk having a frameWidth or frameHeight larger than the new image size, hitting the above mentioned bug. The timer was there just to avoid (re)loading twice in case both themeName and cursorName changes. But that's such a rare case that it's not worth optimizing for it. (LP: #1588929)

commitf01eb10264c69d6a1c1ca1ab1787cfd30b0e0215 authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateFri 17 Jun 2016, 01:18 (10 years ago) parent2e3cdf672dc7a9
2 files changed+2−16
plugins/Cursor/CursorImageInfo.cpp+2−12 plugins/Cursor/CursorImageInfo.h−4
plugins/Cursor/CursorImageInfo.cpp+2−12
@@ -19,17 +19,14 @@
1919CursorImageInfo::CursorImageInfo(QObject *parent)
2020 : QObject(parent)
2121{
22− m_updateTimer.setInterval(0);
23− m_updateTimer.setSingleShot(true);
24− connect(&m_updateTimer, &QTimer::timeout, this, &CursorImageInfo::update);
2522}
2623
2724void CursorImageInfo::setCursorName(const QString &cursorName)
2825{
2926 if (cursorName != m_cursorName) {
3027 m_cursorName = cursorName;
28+ update();
3129 Q_EMIT cursorNameChanged();
32− scheduleUpdate();
3330 }
3431}
3532
@@ -37,15 +34,8 @@ void CursorImageInfo::setThemeName(const QString &themeName)
3734{
3835 if (m_themeName != themeName) {
3936 m_themeName = themeName;
37+ update();
4038 Q_EMIT themeNameChanged();
41− scheduleUpdate();
42− }
43−}
44−
45−void CursorImageInfo::scheduleUpdate()
46−{
47− if (!m_updateTimer.isActive()) {
48− m_updateTimer.start();
4939 }
5040}
5141
plugins/Cursor/CursorImageInfo.h−4
@@ -21,7 +21,6 @@
2121
2222#include <QObject>
2323#include <QString>
24−#include <QTimer>
2524
2625class CursorImageInfo : public QObject
2726{
@@ -64,9 +63,6 @@ private Q_SLOTS:
6463 void update();
6564
6665private:
67− void scheduleUpdate();
68− QTimer m_updateTimer;
69−
7066 QString m_themeName;
7167 QString m_cursorName;
7268