Ask / Submit
8

[howto] [SDK] Fix TypeError messages in DialogHeader.qml and Utils.js

asked 2018-11-29 20:36:30 +0200

Direc gravatar image

updated 2019-11-09 13:10:25 +0200

Edit: Util.js was fixed at some point. I noticed it now with Sailfish SDK 2.3 / SFOS 3.2.0.12.


Please be careful when editing Sailfish OS system files. If you don't know what you are doing, you may need to reflash you device. I'm not giving you step-by-step instructions how to fix the issue; if you found your way to this question you probably can figure out the necessary steps yourself. Always take backups first!

This "question" is related to this question, but I figured out a way to fix another issue as well in a very similar manner, so I'm posting the solution as a separate question.

So, I kept getting these error messages again and again and just couldn't get rid of them:

[W] unknown:38 - file:///usr/lib/qt5/qml/Sailfish/Silica/private/Util.js:38: TypeError: Cannot read property 'parent' of null
[W] unknown:190 - file:///usr/lib/qt5/qml/Sailfish/Silica/DialogHeader.qml:190: TypeError: Cannot read property 'backIndicatorDown' of null
[W] unknown:195 - file:///usr/lib/qt5/qml/Sailfish/Silica/DialogHeader.qml:195: TypeError: Cannot read property 'backIndicatorDown' of null
[W] unknown:243 - file:///usr/lib/qt5/qml/Sailfish/Silica/DialogHeader.qml:243: TypeError: Cannot read property 'forwardIndicatorDown' of null
[W] unknown:248 - file:///usr/lib/qt5/qml/Sailfish/Silica/DialogHeader.qml:248: TypeError: Cannot read property 'forwardIndicatorDown' of null

So I took a look inside those files using the Sailfish SDK emulator. These are the rows that give out the errors, respectively:

var parentItem = item.parent // Util.js:38
highlighted: pageStack._pageStackIndicator.backIndicatorDown || down // DialogHeader.qml:190
value: pageStack._pageStackIndicator.backIndicatorDown || cancelButton.down // DialogHeader.qml:195
highlighted: pageStack._pageStackIndicator.forwardIndicatorDown || down // DialogHeader.qml:243
value: pageStack._pageStackIndicator.forwardIndicatorDown || acceptButton.down // DialogHeader.qml:248

I read the code around a bit, and it really is what the error tells: code tries to yse a property of an object without checking that it is not null. So, I tried these modifications:

var parentItem = item ? item.parent : null // Util.js:38
highlighted: pageStack._pageStackIndicator && pageStack._pageStackIndicator.backIndicatorDown || down // DialogHeader.qml:190
value: pageStack._pageStackIndicator && pageStack._pageStackIndicator.backIndicatorDown || cancelButton.down // DialogHeader.qml:195
highlighted: pageStack._pageStackIndicator && pageStack._pageStackIndicator.forwardIndicatorDown || down // DialogHeader.qml:243
value: pageStack._pageStackIndicator && pageStack._pageStackIndicator.forwardIndicatorDown || acceptButton.down // DialogHeader.qml:248

Please note that I haven't triple typo checked these lines!

The run time error messages no longer appear in the emulator. I've also made the changes in my Sony Xperia XA2 Ultra. I tried to access a lot of places, and it seems to work just fine. When I start .e.g. harbour-picross from command line and enter the level selection screen, I don't see the error messages appearing. When I started the same application from my unmodified Jolla 1 command line, I still got the error messages. In conclusion, after half an hour trying to find a thing in my device that wouldn't work anymore: LGTM

edit retag flag offensive close delete

1 Answer

Sort by » oldest newest most voted
0

answered 2018-11-30 10:32:56 +0200

Pekka Vuorela gravatar image

There are some annoying errors like this, which could be avoided with more guards, but then again for most they seem like Qt bugs, not properly filtering out error states while object is being incubated etc. Hoping new Qt versions would get rid of some.

edit flag offensive delete publish link more
Login/Signup to Answer

Question tools

Follow
5 followers

Stats

Asked: 2018-11-29 20:36:30 +0200

Seen: 222 times

Last updated: Nov 09