PDA

View Full Version : repeater polish() loop on ios



joko
10th March 2015, 14:00
Hi Qt Masters,

I am having error polish() loop in iOS when binding image source using repeater.
However no such error appeared when building it in Android.
When I tried debugging (putting logs), found out that the repeater populates the image row twice then loop error, which made me conclude that the error is due to repeater population.
I can't find any error in the code which triggers the display of the image row twice or more.
Is there a way to limit the repeater to populate only once on first display?
Except when there is mouse interaction because new image source will be displayed.
Thanks in advance.



Item
{
id: root

property int currLevel: 1
property bool disabled: currLevel <= 0

Layout.fillWidth: true

implicitHeight: row.implicitHeight
implicitWidth: row.implicitWidth

Row {
id: row
anchors.fill: parent

Repeater
{
id:repeater

model: 10

Image {
id: img

function urlForState(disabled, hover, active) {
if(disabled && active) return "img-disabled.png"
if(disabled) return "img-off.png"

if (active) {
if (hover) return "img-on-over.png"
return "img-on.png"
} else {
if (hover) return "img-off-over.png"
return "img-off.png"
}
}

width: row.width/model
fillMode: Image.PreserveAspectFit

source: urlForState(root.disabled, mouseArea.pressed, root.currLevel > index)
}
}
}

MouseArea
{
id: mouseArea

anchors.fill: parent

hoverEnabled: true
}
}

wysota
10th March 2015, 14:51
What is the error you are getting?

joko
10th March 2015, 16:35
What is the error you are getting?

Thanks for the quick reply wysota.

The errors appeared on the application output were few lines of this:

QQuickWindow: possible QQuickItem:: polish() loop

Then the page will froze.

Added after 1 17 minutes:

After carefully examining my code, i found out the reason why repeater populates the row twice because I set the "currLevel = 1" then the parent of the element, set the currLevel on Component.oncompleted. So the first instance of the population of images was based on the initial value, then re-populate again once oncompleted signal is called.

Any advice how to simplify it? And also, any idea why this only occurred on iOS compiler? TIA.

wysota
10th March 2015, 18:44
Set the repeater's model in Component.onCompleted when currLevel is already set.

joko
11th March 2015, 09:43
Set the repeater's model in Component.onCompleted when currLevel is already set.

That didn't resolved the issue though it only populates the repeater delegate once.
However after emitting the width property on Image component, the loop error disappeared.
Setting the width on image equally placed them on the center (in Android) while in iOS without setting the width, they're placed on the center already.

Is there a known issue like this in iOS? Thanks.

joko
13th March 2015, 13:55
Hi again,

I am having an error when the row width changes, do you have any advise how to set the image width within the repeater?
I tried creating a variable that will handle the img width, which will be set once onWidthChanged signal of the row, but the same error.
And also tried creating a javascript binded to img component which will return row.width/model.
Thanks.

ERROR:
I/dalvikvm(10614): threadid=3: reacting to signal 3
I/dalvikvm(10614): Wrote stack traces to '/data/anr/traces.txt'



Item
{
id: root

Layout.fillWidth: true

implicitHeight: row.implicitHeight
implicitWidth: row.implicitWidth

Row {
id: row
anchors.fill: parent

Repeater
{
id:repeater

model: 10

Image {
id: img

width: row.width/model // this is the line of code that is causing the problem
fillMode: Image.PreserveAspectFit

source: "img.png"
}
}
}
}

wysota
13th March 2015, 15:02
I don't understand what you mean. What row width changes do you mean?

joko
13th March 2015, 15:29
I don't understand what you mean. What row width changes do you mean?

The row component which is the parent of the Repeater is what I am referring to.
I think the issue occurred when its width changes (once orientation changes) and when the repeater populates the images using this equation "row.width/model", am I right?

wysota
13th March 2015, 15:35
The code doesn't look suspicious. It should work without problems.