on xenial help sign in
Work around AnimatedSprite infinite loop bug
0ec559bDaniel d'Andrada
plugins/Cursor/Cursor.qml+4−1
@@ -29,7 +29,10 @@ MousePointer {
29 AnimatedSprite {
29 AnimatedSprite {
30 x: -imageInfo.hotspot.x
30 x: -imageInfo.hotspot.x
31 y: -imageInfo.hotspot.y
31 y: -imageInfo.hotspot.y
32+
33+ // The only reason of the ready property is to work around https://bugreports.qt.io/browse/QTBUG-53937
32− source: "image://cursor/" + mousePointer.themeName + "/" + mousePointer.cursorName
34+ source: imageInfo.ready ? "image://cursor/" + mousePointer.themeName + "/" + mousePointer.cursorName
35+ : ""
33
36
34 interpolate: false
37 interpolate: false
35
38
plugins/Cursor/CursorImageInfo.cpp+15−2
@@ -27,24 +27,28 @@ CursorImageInfo::CursorImageInfo(QObject *parent)
27void CursorImageInfo::setCursorName(const QString &cursorName)
27void CursorImageInfo::setCursorName(const QString &cursorName)
28{
28{
29 if (cursorName != m_cursorName) {
29 if (cursorName != m_cursorName) {
30+ scheduleUpdate();
30 m_cursorName = cursorName;
31 m_cursorName = cursorName;
31 Q_EMIT cursorNameChanged();
32 Q_EMIT cursorNameChanged();
32− scheduleUpdate();
33 }
33 }
34}
34}
35
35
36void CursorImageInfo::setThemeName(const QString &themeName)
36void CursorImageInfo::setThemeName(const QString &themeName)
37{
37{
38 if (m_themeName != themeName) {
38 if (m_themeName != themeName) {
39+ scheduleUpdate();
39 m_themeName = themeName;
40 m_themeName = themeName;
40 Q_EMIT themeNameChanged();
41 Q_EMIT themeNameChanged();
41− scheduleUpdate();
42 }
42 }
43}
43}
44
44
45void CursorImageInfo::scheduleUpdate()
45void CursorImageInfo::scheduleUpdate()
46{
46{
47 if (!m_updateTimer.isActive()) {
47 if (!m_updateTimer.isActive()) {
48+ if (m_ready) {
49+ m_ready = false;
50+ Q_EMIT readyChanged();
51+ }
48 m_updateTimer.start();
52 m_updateTimer.start();
49 }
53 }
50}
54}
@@ -58,6 +62,10 @@ void CursorImageInfo::update()
58 Q_EMIT frameHeightChanged();
62 Q_EMIT frameHeightChanged();
59 Q_EMIT frameCountChanged();
63 Q_EMIT frameCountChanged();
60 Q_EMIT frameDurationChanged();
64 Q_EMIT frameDurationChanged();
65+
66+ Q_ASSERT(!m_ready);
67+ m_ready = true;
68+ Q_EMIT readyChanged();
61}
69}
62
70
63QPoint CursorImageInfo::hotspot() const
71QPoint CursorImageInfo::hotspot() const
@@ -104,3 +112,8 @@ int CursorImageInfo::frameDuration() const
104 return 0;
112 return 0;
105 }
113 }
106}
114}
115+
116+bool CursorImageInfo::ready() const
117+{
118+ return m_ready;
119+}
plugins/Cursor/CursorImageInfo.h+8
@@ -36,6 +36,10 @@ class CursorImageInfo : public QObject
36 Q_PROPERTY(int frameCount READ frameCount NOTIFY frameCountChanged)
36 Q_PROPERTY(int frameCount READ frameCount NOTIFY frameCountChanged)
37 Q_PROPERTY(int frameDuration READ frameDuration NOTIFY frameDurationChanged)
37 Q_PROPERTY(int frameDuration READ frameDuration NOTIFY frameDurationChanged)
38
38
39+ // Will be true when all properties are in sync and false while they're
40+ // being updated to reflect a change in themeName or cursorName.
41+ Q_PROPERTY(bool ready READ ready NOTIFY readyChanged)
42+
39public:
43public:
40 CursorImageInfo(QObject *parent = nullptr);
44 CursorImageInfo(QObject *parent = nullptr);
41
45
@@ -50,6 +54,7 @@ public:
50 qreal frameHeight() const;
54 qreal frameHeight() const;
51 int frameCount() const;
55 int frameCount() const;
52 int frameDuration() const;
56 int frameDuration() const;
57+ bool ready() const;
53
58
54Q_SIGNALS:
59Q_SIGNALS:
55 void themeNameChanged();
60 void themeNameChanged();
@@ -59,6 +64,7 @@ Q_SIGNALS:
59 void frameHeightChanged();
64 void frameHeightChanged();
60 void frameCountChanged();
65 void frameCountChanged();
61 void frameDurationChanged();
66 void frameDurationChanged();
67+ void readyChanged();
62
68
63private Q_SLOTS:
69private Q_SLOTS:
64 void update();
70 void update();
@@ -71,6 +77,8 @@ private:
71 QString m_cursorName;
77 QString m_cursorName;
72
78
73 CursorImage *m_cursorImage{nullptr};
79 CursorImage *m_cursorImage{nullptr};
80+
81+ bool m_ready{false};
74};
82};
75
83
76#endif // CURSOR_IMAGE_INFO_H
84#endif // CURSOR_IMAGE_INFO_H