Bug 514131

Summary: KWin permanently caches QML files in KWin scripts, making development harder
Product: [Plasma] kwin Reporter: Gerry Hernandez <gerry>
Component: scriptingAssignee: KWin default assignee <kwin-bugs-null>
Status: CONFIRMED ---    
Severity: wishlist CC: bugs.kde.org, gerry, kde, nate
Priority: NOR    
Version First Reported In: 6.5.3   
Target Milestone: ---   
Platform: Bazzite   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=481007
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Gerry Hernandez 2026-01-04 00:08:47 UTC
# 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.
Comment 1 David Edmundson 2026-01-05 11:22:45 UTC
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.
Comment 2 David Edmundson 2026-01-05 16:58:45 UTC
update: qmlpreview isn't flexible enough