Is it possible to use any QML Parser Tool?
-
Hi
I have not seen any such tools but you could roll your own using the parser from Qt
https://code.woboq.org/qt5/qtdeclarative/src/qml/parser/ -
Are you looking to do error-checking and error-prevention by ensuring (before "shipping" an application) that all your C++ types that should be registered are, indeed, actually properly registered?
If that is your goal, then I commend you. I am interested in that topic as well.
So far, I have been able to greatly increase detection of many such issues using a combination of:
- total ban on "qml warnings". (things that qml prints as "warnings" tend to be what I consider fatal bugs).
- launch the application during automated testing
- use automated scripts to scan the output of the launched application for any forbidden output such as "unregistered datatype" and "failed to load component"
The ban on warnings that I mention in point (1) is achieved by installing (in C++) a Qt custom message handler to spy on all logged messages and abort if any messages are "warnings" emanating from a
qml
file: https://github.com/219-design/qt-qml-project-template-with-ci/blob/4d81552d77/src/app/qml_message_interceptor.cc#L44Launching the application during C.I. on a headless machine is done with Xvfb: https://github.com/219-design/qt-qml-project-template-with-ci/blob/4d81552d772c32b7d62edb4b4f0f678ca92bed4f/run_all_tests.sh#L50
The warnings-ban could be used on any platform.
The
Xvfb
automation, to my knowledge, would be limited to Linux applications. Therefore a parser-based detection system could be a more cross-platform portable solution.If you come up with a parsing-based solution, I'm sure that I and many other users that combine C++ with QML would be happy to try out your solution.
-
This post is deleted!
-