diff options
author | Mitch Curtis <mitch.curtis@theqtcompany.com> | 2015-09-24 10:05:37 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@theqtcompany.com> | 2015-09-25 09:49:22 +0000 |
commit | 5f23d4eb103baa21225adb4c3dd666dbefef6515 (patch) | |
tree | 9da1f4838842a329058043fefdf6c2f153f134fd | |
parent | 9794e7d66c30f012a19ec9530d719293b7c5bc7c (diff) |
Image: fix crash when switching between multiple screens
When moving a Qt Quick application containing Image delegates in a view
(e.g. ListView, GridView, etc.) between multiple screens, it's possible
that the amount of visible delegates changes due to potential
differences in the screens' sizes.
For example, moving an application using the Window + left/right arrow
keys on Windows causes the window to snap to the side of the screen.
If one screen is smaller than the other, moving the application back
and forth in this manner will cause some delegates to be destroyed, as
they are no longer visible in the smaller screen.
However, between receiving the Component.destruction signal in QML and
being actually destroyed in C++, the Images may try to reload their
pixmaps (when the cache property is set to false, for example). Since
the views had (correctly) already hidden those delegates and hence
they had no associated QQmlEngine, the load() function would crash
because of the assumption that there was a valid engine.
This patch checks that there is a valid QQmlEngine with which to load
pixmaps before doing so.
Change-Id: I8a3f0ec5220fddfd79758985c1eb2b55b0baae47
Task-number: QTBUG-45991
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
-rw-r--r-- | src/quick/items/qquickimagebase.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/quick/items/qquickimagebase.cpp b/src/quick/items/qquickimagebase.cpp index 223cb8f46f..72325243df 100644 --- a/src/quick/items/qquickimagebase.cpp +++ b/src/quick/items/qquickimagebase.cpp @@ -308,7 +308,7 @@ void QQuickImageBase::itemChange(ItemChange change, const ItemChangeData &value) void QQuickImageBase::handleScreenChanged(QScreen* screen) { // Screen DPI might have changed, reload images on screen change. - if (screen && isComponentComplete()) + if (qmlEngine(this) && screen && isComponentComplete()) load(); } |