# SUMMARY When re-loading a KWin `declarativescript` script during a local development workflow, KWin only loads a cached version of each QML file. After the initial load, any changes to the contents of the QML files are ignored. # STEPS TO REPRODUCE I've created a minimal KWin `declarativescript` example, available at https://github.com/gplusplus314/kwin-helloworld complete with reproduction instructions in the `README.md`. Here is a high level reproduction: 1. Create a KWin `declarativescript` with a `main.qml` file that contains a "Hello World" of sorts. 2. Install, enable, and start the script. You will see "Hello World". 3. Disable and uninstall the script. 4. Change the text in `main.qml` to say "Hello KWin". 5. Disable, uninstall, reinstall, reload the script. # OBSERVED RESULT "Hello World" # EXPECTED RESULT "Hello KWin" # SOFTWARE/OS VERSIONS Linux Kernel: 6.17.7-ba22.fc43.x86_64 KDE Plasma Version: 6.5.4 KDE Frameworks Version: 6.21.0 Qt Version: 6.10.1 # ADDITIONAL INFORMATION I found a similar issue in another project that uses QML and they've resolved it by exposing https://doc.qt.io/qt-6/qqmlengine.html#clearComponentCache in their API. Here is the issue: https://github.com/JuliaGraphics/QML.jl/issues/195 The only workaround I can find to forcefully invalidate the QML cache in KWin is to restart KWin altogether, which is very disruptive. It would be helpful to either perform a `clearComponentCache` upon unload, or even just expose it via `dbus`, or any other mechanism that would allow us to have a working development loop/workflow for KWin scripts in QML.
Exposing via dbus would be fine. Doing anything more automatic would slow down the common user case for a super niche development case. Calling trimComponentCache on script unload might be ok if that suffices. --- We should also test how well it works with qmlpreview (https://doc.qt.io/qt-6/qtqml-tooling-qmlpreview.html) Unfortunately it requires the developer to rebuild kwin once with a flag set, but if it does work it would be even more streamlined for everyone.
update: qmlpreview isn't flexible enough