aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquickimageprovider.h
diff options
context:
space:
mode:
authorSimon Hausmann <[email protected]>2018-05-16 17:38:37 +0200
committerSimon Hausmann <[email protected]>2018-05-17 12:39:51 +0000
commit38dc69ae01d2ba733fb35f7c8d26500062858798 (patch)
tree523ed25bb2fc513f675da97679d8d50b5d24a91e /src/quick/util/qquickimageprovider.h
parent7cb6dce1f3e140ea68d6b05281950f212fc99d38 (diff)
Fix race condition in async image response handling
It may happen that the finished() signal is emitted from a super quick image loading thread in the implementation before we had a chance to connect to the signal in Qt Quick. In that case, record the emission through a private connection established in the constructor. The unit test simulates this scenario by emitting the signal before returning the object, but in a real world scenario it may happen that the response object is used in a separate thread that ends up emitting the signal. That may also happen before the thread that will try to connect to the signal runs. Task-number: QTBUG-59601 Change-Id: I14de9719db47f4bca2e8a2c6659343cfb4deb526 Reviewed-by: Albert Astals Cid <[email protected]>
Diffstat (limited to 'src/quick/util/qquickimageprovider.h')
-rw-r--r--src/quick/util/qquickimageprovider.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/quick/util/qquickimageprovider.h b/src/quick/util/qquickimageprovider.h
index 4f8193789a..82d0501697 100644
--- a/src/quick/util/qquickimageprovider.h
+++ b/src/quick/util/qquickimageprovider.h
@@ -69,6 +69,8 @@ public:
static QQuickTextureFactory *textureFactoryForImage(const QImage &image);
};
+class QQuickImageResponsePrivate;
+
class Q_QUICK_EXPORT QQuickImageResponse : public QObject
{
Q_OBJECT
@@ -84,6 +86,10 @@ public Q_SLOTS:
Q_SIGNALS:
void finished();
+
+private:
+ Q_DECLARE_PRIVATE(QQuickImageResponse)
+ Q_PRIVATE_SLOT(d_func(), void _q_finished())
};
class Q_QUICK_EXPORT QQuickImageProvider : public QQmlImageProviderBase