on xenial help sign in
Fix 'Binding loop detected for property "imageAspectRatio"'
commit5bf7cdae686d47fd1d301606695980f1c61eeca9 authorAlbert Astals Cid <albert.astals@canonical.com> dateWed 21 Oct 2015, 16:47 (11 years ago) parentcab9943
1 file changed+13−4
plugins/Dash/CroppedImageMinimumSourceSize.qml+13−4
plugins/Dash/CroppedImageMinimumSourceSize.qml+13−4
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2014, 2015 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -21,7 +21,16 @@ Image {
2121
2222 fillMode: Image.PreserveAspectCrop
2323
24− readonly property real itemAspectRatio: width / height
25− readonly property real imageAspectRatio: implicitWidth / implicitHeight
26− sourceSize: (imageAspectRatio > itemAspectRatio) ? Qt.size(0, height) : Qt.size(width, 0)
24+ property bool useHeight: false
25+ function updateUseHeight()
26+ {
27+ useHeight = (implicitWidth / implicitHeight) > (width / height);
28+ }
29+
30+ onHeightChanged: updateUseHeight();
31+ onWidthChanged: updateUseHeight();
32+ onImplicitHeightChanged: updateUseHeight();
33+ onImplicitWidthChanged: updateUseHeight();
34+
35+ sourceSize: useHeight ? Qt.size(0, height) : Qt.size(width, 0)
2736}