Sometimes QML property binding doesn't updates
-
I have the next code:
property int maxCount: convert(isMaxUser ? user.maxUserCount : admin.maxAdminCount) Label{ text: maxCount.toString() }
At all it works good, but sometimes maxCount value is stuck, it doesn't changes anymore. It occurs very seldom and I don't know how I can use property binding in the best way to avoid this strange behaviour.
I've tried to update maxCount velue in this way:
property int maxUser: user.maxUserCount property int maxAdmin: admin.maxAdminCount property int maxCount: convert(isMaxUser ? maxUser : maxAdmin) onMaxAdminChanged{ maxCount= convert(isMaxUser ? maxUser : maxAdmin) } onMaxUserChanged{ maxCount= convert(isMaxUser ? maxUser : maxAdmin) }
But I think that this way is too complex.
Can you advise me something to solve my issue in the best way?
Thanks a lot!
-
I have the next code:
property int maxCount: convert(isMaxUser ? user.maxUserCount : admin.maxAdminCount) Label{ text: maxCount.toString() }
At all it works good, but sometimes maxCount value is stuck, it doesn't changes anymore. It occurs very seldom and I don't know how I can use property binding in the best way to avoid this strange behaviour.
I've tried to update maxCount velue in this way:
property int maxUser: user.maxUserCount property int maxAdmin: admin.maxAdminCount property int maxCount: convert(isMaxUser ? maxUser : maxAdmin) onMaxAdminChanged{ maxCount= convert(isMaxUser ? maxUser : maxAdmin) } onMaxUserChanged{ maxCount= convert(isMaxUser ? maxUser : maxAdmin) }
But I think that this way is too complex.
Can you advise me something to solve my issue in the best way?
Thanks a lot!
At first, just for debug you can do this:
property int maxCount: { print("isMaxUser: " + isMaxUser) print("user.maxUserCount: " + user.maxUserCount) print("admin.maxAdminCount: " + admin.maxAdminCount) var res = convert(isMaxUser ? user.maxUserCount : admin.maxAdminCount); print("res: " + res) return res; }
This will help you to catch a case of stuck.
This is entry point to solve your problem. -
I've found that sometimes (very seldom 1 from 50) binding to method doesn't work.
I've separated property and method call in that way:property int value: isMaxUser ? user.maxUserCount : admin.maxAdminCount property int maxCount: convert(value) onValueChanged: { maxCount = convert(value) }
I hope this issue won't reproduce anymore...
-
I've found that sometimes (very seldom 1 from 50) binding to method doesn't work.
I've separated property and method call in that way:property int value: isMaxUser ? user.maxUserCount : admin.maxAdminCount property int maxCount: convert(value) onValueChanged: { maxCount = convert(value) }
I hope this issue won't reproduce anymore...
@Manta-Ray
Which binding doesn't work?
Could you give us a trace logged code with logs? -
@Manta-Ray
Which binding doesn't work?
Could you give us a trace logged code with logs?@Roumed said in Sometimes QML property binding doesn't updates:
Could you give us a trace logged code with logs?
Or at least the whole project/code and instructions how to try to reproduce the problem. This looks interesting if it really does happen without a bug in your code.
-
Sometimes this:
property int maxCount: convert(isMaxUser ? user.maxUserCount : admin.maxAdminCount)
doesn't work. I see the log message in backend before emit signal user.maxUserCountChanged, then I see that label doesn't changes and doesn't see log message in convert method. So I decided that sometimes, depends on CPU usage or count of processes in the system or something else this method doesn't call. It happens very-very seldom, maybe 1 from100 times.
-
Sometimes this:
property int maxCount: convert(isMaxUser ? user.maxUserCount : admin.maxAdminCount)
doesn't work. I see the log message in backend before emit signal user.maxUserCountChanged, then I see that label doesn't changes and doesn't see log message in convert method. So I decided that sometimes, depends on CPU usage or count of processes in the system or something else this method doesn't call. It happens very-very seldom, maybe 1 from100 times.
@Manta-Ray What is convert() ?
-
@Manta-Ray What is convert() ?
@Eeli-K This is the method which rounds values.
I can't show you the original code, but it looks like:.cpp if(...){ print("Max user count changed: %d", maxUserCount); emit maxUserCountChanges(); } .qml property int maxCount: convert(isMaxUser ? user.maxUserCount : admin.maxAdminCount) onMaxCountChanged:{ console.log("Max count changed: ", maxCount) } Label{ text: maxCount.toString() } function convert(int val){ console.log("Convert value: ", val) ....... }
During work I see the next logs:
123.12 Max user count changed: 4And never see:
Convert value: 4
or
Max count changed: 4It works almost always but sometimes...
-
@Eeli-K This is the method which rounds values.
I can't show you the original code, but it looks like:.cpp if(...){ print("Max user count changed: %d", maxUserCount); emit maxUserCountChanges(); } .qml property int maxCount: convert(isMaxUser ? user.maxUserCount : admin.maxAdminCount) onMaxCountChanged:{ console.log("Max count changed: ", maxCount) } Label{ text: maxCount.toString() } function convert(int val){ console.log("Convert value: ", val) ....... }
During work I see the next logs:
123.12 Max user count changed: 4And never see:
Convert value: 4
or
Max count changed: 4It works almost always but sometimes...
@Manta-Ray
We definitely need to know more about your environment. -
@Manta-Ray
We definitely need to know more about your environment. -
@Roumed Application is working on ubuntu 14.04. I don't have an information about hardware.
@Manta-Ray
If this really is a bug in Qt, it's important. Could you at least create a project, as small as possible, which would produce the same problem? It's impossible to help, find the bug and fix it if you can't show exactly how it can be reproduced, especially when it's random. Also information about the hardware is necessary if it doesn't happen to others with their platform.