aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquickimageprovider.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2018-05-16 17:38:37 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-05-17 12:39:51 +0000
commit38dc69ae01d2ba733fb35f7c8d26500062858798 (patch)
tree523ed25bb2fc513f675da97679d8d50b5d24a91e /src/quick/util/qquickimageprovider.cpp
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 <albert.astals.cid@kdab.com>
Diffstat (limited to 'src/quick/util/qquickimageprovider.cpp')
-rw-r--r--src/quick/util/qquickimageprovider.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/quick/util/qquickimageprovider.cpp b/src/quick/util/qquickimageprovider.cpp
index 2bb2af4fc0..7c61affe75 100644
--- a/src/quick/util/qquickimageprovider.cpp
+++ b/src/quick/util/qquickimageprovider.cpp
@@ -39,8 +39,10 @@
#include "qquickimageprovider.h"
+#include "qquickimageprovider_p.h"
#include "qquickpixmapcache_p.h"
#include <QtQuick/private/qsgcontext_p.h>
+#include <private/qqmlglobal_p.h>
QT_BEGIN_NAMESPACE
@@ -160,7 +162,10 @@ QQuickTextureFactory *QQuickTextureFactory::textureFactoryForImage(const QImage
Constructs the image response
*/
QQuickImageResponse::QQuickImageResponse()
+ : QObject(*(new QQuickImageResponsePrivate))
{
+ qmlobject_connect(this, QQuickImageResponse, SIGNAL(finished()),
+ this, QQuickImageResponse, SLOT(_q_finished()));
}
/*!