Merge lp:~tpeeters/ubuntu-ui-toolkit/crossFadeImage_SourceSize_fix into lp:ubuntu-ui-toolkit

Proposed by Tim Peeters
Status: Merged
Approved by: Tim Peeters
Approved revision: 781
Merged at revision: 798
Proposed branch: lp:~tpeeters/ubuntu-ui-toolkit/crossFadeImage_SourceSize_fix
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 143 lines (+71/-2)
4 files modified
CHANGES (+1/-0)
components.api (+1/-1)
modules/Ubuntu/Components/CrossFadeImage.qml (+43/-1)
tests/unit/tst_components/tst_CrossFadeImage.qml (+26/-0)
To merge this branch: bzr merge lp:~tpeeters/ubuntu-ui-toolkit/crossFadeImage_SourceSize_fix
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Tim Peeters Approve
Zsombor Egri Needs Fixing
Günter Schwann (community) Approve
Michael Zanetti (community) Needs Information
Review via email: mp+187454@code.launchpad.net

Commit message

Update CrossFadeImage API so that sourceSize can be set by the applications.

* CHANGED in CrossFadeImage: readonly property size sourceSize TO property size sourceSize

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

59 + } else if (internals.loadingImage && (sourceSize != Qt.size(internals.loadingImage.sourceSize.width, internals.loadingImage.sourceSize.height))) {

Hmm... Can it be that internals.loadingImage is null at some point? In that case setting the sourceSize would get lost if setting during that period. If it can't happen we can probably drop this check either. In any case I think the "internals.loadingImage &&" should not be here as the sourceSize gets bound to currentImage and nextImage directly anyways.

No tests?

review: Needs Information
Revision history for this message
Günter Schwann (schwann) wrote :

looks good, and helps fixing the issue decscribed in the bug

review: Approve
Revision history for this message
Tim Peeters (tpeeters) wrote :

> 59 + } else if (internals.loadingImage && (sourceSize !=
> Qt.size(internals.loadingImage.sourceSize.width,
> internals.loadingImage.sourceSize.height))) {
>
> Hmm... Can it be that internals.loadingImage is null at some point? In that
> case setting the sourceSize would get lost if setting during that period. If
> it can't happen we can probably drop this check either. In any case I think
> the "internals.loadingImage &&" should not be here as the sourceSize gets
> bound to currentImage and nextImage directly anyways.

apparently it can be null/undefined when the object is being created and image pointers are not yet set.

>
> No tests?

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

> > 59 + } else if (internals.loadingImage && (sourceSize !=
> > Qt.size(internals.loadingImage.sourceSize.width,
> > internals.loadingImage.sourceSize.height))) {
> >
> > Hmm... Can it be that internals.loadingImage is null at some point? In that
> > case setting the sourceSize would get lost if setting during that period. If
> > it can't happen we can probably drop this check either. In any case I think
> > the "internals.loadingImage &&" should not be here as the sourceSize gets
> > bound to currentImage and nextImage directly anyways.
>
> apparently it can be null/undefined when the object is being created and image
> pointers are not yet set.

Yeah, this is what I meant. So doesn't this fail in that case?

I mean, if you're using it like this:

CrossFadeImage {
   source: "foo.png"
   sourceSize.height: 500
   sourceSize.width: 500
}

Given that the whole thing is built up and sourceSize is set immediately, when loadingImage is still null. The sourceSize setting would just be discarded afaics. Unless the constructions happens before the property setting. In that case the check doesn't break anything, but is still useles..

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Zsombor Egri (zsombi) wrote :

52 +
53 + onSourceSizeChanged: {

qdoc failure given on this line. Also remember to merge trunk, there were issues with autopilot tests.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Tim Peeters (tpeeters) wrote :

> > > 59 + } else if (internals.loadingImage && (sourceSize !=
> > > Qt.size(internals.loadingImage.sourceSize.width,
> > > internals.loadingImage.sourceSize.height))) {
> > >
> > > Hmm... Can it be that internals.loadingImage is null at some point? In
> that
> > > case setting the sourceSize would get lost if setting during that period.
> If
> > > it can't happen we can probably drop this check either. In any case I
> think
> > > the "internals.loadingImage &&" should not be here as the sourceSize gets
> > > bound to currentImage and nextImage directly anyways.
> >
> > apparently it can be null/undefined when the object is being created and
> image
> > pointers are not yet set.
>
> Yeah, this is what I meant. So doesn't this fail in that case?
>
> I mean, if you're using it like this:
>
> CrossFadeImage {
> source: "foo.png"
> sourceSize.height: 500
> sourceSize.width: 500
> }
>
> Given that the whole thing is built up and sourceSize is set immediately, when
> loadingImage is still null. The sourceSize setting would just be discarded
> afaics. Unless the constructions happens before the property setting. In that
> case the check doesn't break anything, but is still useles..

I added a test that checks for explicitly defined source sizes.

If no image is loaded yet, sourceSize is set to 0,0, and setting it implicitly will trigger a changed and will set forcedSourceSize, and as a result the image sourceSize will be ignored in the future. So it all seems good.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Francis Ginther (fginther) wrote :

maguro device was stuck, re-building.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Tim Peeters (tpeeters) wrote :

let's see if stuff gets merged now.

review: Approve
Revision history for this message
Tim Peeters (tpeeters) wrote :

just need positive CI results

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Autolanding.
More details in the following jenkins job:
http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-autolanding/377/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-saucy-vm/415
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-touch/3041
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-amd64-autolanding/304
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-armhf-autolanding/303
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-armhf-autolanding/303/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-vm-saucy/312
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/4563
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/4563/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/3043
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/3043/artifact/work/output/*zip*/output.zip
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2548
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2599
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/122
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/123

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:781
http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-ci/998/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-saucy-vm/417
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-touch/3043
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-amd64-ci/855
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-armhf-ci/855
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-ui-toolkit-saucy-armhf-ci/855/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-vm-saucy/314
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/4565
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-i386/4565/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/3045
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-saucy-armhf/3045/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-maguro/2550
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/2601
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/130
    SUCCESS: http://10.97.0.26:8080/job/touch-flash-device/131

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/ubuntu-ui-toolkit-ci/998/rebuild

review: Approve (continuous-integration)
Revision history for this message
Tim Peeters (tpeeters) wrote :

approved by jenkins??! woohoo!!! :)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CHANGES'
2--- CHANGES 2013-10-02 06:38:07 +0000
3+++ CHANGES 2013-10-14 08:32:19 +0000
4@@ -55,6 +55,7 @@
5 * ADDED IN Panel: function open()
6 * ADDED IN Panel: function close()
7 * DEPRECATED IN Panel: writable property opened. Will be made read-only.
8+* CHANGED in CrossFadeImage: readonly property size sourceSize TO property size sourceSize
9
10 Compatibility Breaks
11 ********************
12
13=== modified file 'components.api'
14--- components.api 2013-10-03 06:27:08 +0000
15+++ components.api 2013-10-14 08:32:19 +0000
16@@ -42,7 +42,7 @@
17 property int fillMode
18 property int fadeDuration
19 readonly property bool running
20- readonly property size sourceSize
21+ property size sourceSize
22 readonly property int status
23 modules/Ubuntu/Components/DraggingArea.qml
24 MouseArea
25
26=== modified file 'modules/Ubuntu/Components/CrossFadeImage.qml'
27--- modules/Ubuntu/Components/CrossFadeImage.qml 2013-08-28 12:56:17 +0000
28+++ modules/Ubuntu/Components/CrossFadeImage.qml 2013-10-14 08:32:19 +0000
29@@ -81,8 +81,33 @@
30
31 /*!
32 The actual width and height of the loaded image
33+ This property holds the actual width and height of the loaded image.
34+
35+ Unlike the width and height properties, which scale the painting of the image,
36+ this property sets the actual number of pixels stored for the loaded image so that large
37+ images do not use more memory than necessary.
38+
39+ Note: Changing this property dynamically causes the image source to be reloaded, potentially
40+ even from the network, if it is not in the disk cache.
41 */
42- readonly property size sourceSize: Qt.size(internals.loadingImage.sourceSize.width, internals.loadingImage.sourceSize.height)
43+ // FIXME: Support resetting sourceSize
44+ property size sourceSize: internals.loadingImage ? Qt.size(internals.loadingImage.sourceSize.width, internals.loadingImage.sourceSize.height) : Qt.size(0, 0)
45+
46+ Binding {
47+ target: crossFadeImage
48+ property: "sourceSize"
49+ value: internals.loadingImage ? Qt.size(internals.loadingImage.sourceSize.width, internals.loadingImage.sourceSize.height) : Qt.size(0, 0)
50+ when: internals.forcedSourceSize === undefined
51+ }
52+
53+ /*!
54+ \internal
55+ */
56+ onSourceSizeChanged: {
57+ if (internals.loadingImage && (sourceSize != Qt.size(internals.loadingImage.sourceSize.width, internals.loadingImage.sourceSize.height))) {
58+ internals.forcedSourceSize = sourceSize;
59+ }
60+ }
61
62 /*!
63 \qmlproperty enumeration status
64@@ -102,6 +127,11 @@
65 id: internals
66
67 /*! \internal
68+ Source size specified by the setting crossFadeImage.sourceSize.
69+ */
70+ property size forcedSourceSize
71+
72+ /*! \internal
73 Defines the image currently being shown
74 */
75 property Image currentImage: image1
76@@ -130,6 +160,12 @@
77 asynchronous: true
78 fillMode: parent.fillMode
79 z: 1
80+ Binding {
81+ target: image1
82+ property: "sourceSize"
83+ value: internals.forcedSourceSize
84+ when: internals.forcedSourceSize !== undefined
85+ }
86 }
87
88 Image {
89@@ -139,6 +175,12 @@
90 asynchronous: true
91 fillMode: parent.fillMode
92 z: 0
93+ Binding {
94+ target: image2
95+ property: "sourceSize"
96+ value: internals.forcedSourceSize
97+ when: internals.forcedSourceSize !== undefined
98+ }
99 }
100
101 /*!
102
103=== modified file 'tests/unit/tst_components/tst_CrossFadeImage.qml'
104--- tests/unit/tst_components/tst_CrossFadeImage.qml 2013-07-08 13:44:33 +0000
105+++ tests/unit/tst_components/tst_CrossFadeImage.qml 2013-10-14 08:32:19 +0000
106@@ -35,6 +35,15 @@
107 target: crossFadeImage
108 }
109
110+ CrossFadeImage {
111+ id: crossFadeImagePreset
112+ sourceSize {
113+ width: 123
114+ height: 321
115+ }
116+ source: Qt.resolvedUrl("../../../examples/ubuntu-ui-toolkit-gallery/demo_image.jpg")
117+ }
118+
119 function loadImage(url) {
120 console.log("Loading image...");
121 source = url;
122@@ -93,4 +102,21 @@
123 waitForAnimation();
124 cleanupTest();
125 }
126+
127+ function test_sourceSize() {
128+ loadImage("../../../examples/ubuntu-ui-toolkit-gallery/demo_image.jpg");
129+ compare(crossFadeImage.sourceSize.width, 640, "Source width incorrectly initialized.");
130+ compare(crossFadeImage.sourceSize.height, 427, "Source height incorrectly initialized.");
131+ crossFadeImage.sourceSize.width = 100;
132+ crossFadeImage.sourceSize.height = 101;
133+ compare(crossFadeImage.sourceSize.width, 100, "Source width incorrectly updated.");
134+ compare(crossFadeImage.sourceSize.height, 101, "Source height incorrectly updated.");
135+ waitForAnimation();
136+ cleanupTest();
137+ }
138+
139+ function test_sourcePreset() {
140+ compare(crossFadeImagePreset.sourceSize.width, 123, "Source width incorrectly taken from preset.");
141+ compare(crossFadeImagePreset.sourceSize.height, 321, "Source height incorrectly take from preset.");
142+ }
143 }

Subscribers

People subscribed via source and target branches

to status/vote changes: