Repository navigation
qtui, skins-qt: Use unique window role for plugin windows, fix crash with QT 6.12, follow x11 rule - #215
Conversation
…d crash with qt 6.12.0 & complies with ICCCM 5.1
There was a problem hiding this comment.
🟢 Approval recommended
Both plugin-window hosts consistently use stable dock-item IDs to eliminate role collisions.
0 open findings
What changed in this PR
Prevents Qt 6.12/KWin crashes by assigning each plugin window a unique role based on its dock-item ID.
Changes:
- Uses
plugin-<id>roles in both Qt interfaces. - Preserves distinct window roles across plugin windows.
| File | Description |
|---|---|
src/qtui/main_window.cc |
Assigns unique roles to dock widgets. |
src/skins-qt/plugin-window.cc |
Assigns unique roles to skin plugin windows. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Thanks for the report and pull request. 👍 Could you also please check What happens for example when you add/open files (via the File menu, keeping the dialog open) and then import/export an equalizer preset? src/libaudqt/url-opener-qt.cc: dialog->setWindowRole("url-dialog");
src/libaudqt/audqt.cc: msgbox->setWindowRole("message");
src/libaudqt/colorbutton.cc: dialog->setWindowRole("color-dialog");
src/libaudqt/about-qt.cc: window->setWindowRole("about");
src/libaudqt/infowin-qt.cc: setWindowRole("song-info");
src/libaudqt/prefs-window-qt.cc: setWindowRole("settings");
src/libaudqt/song-window-qt.cc: setWindowRole("jump-to-song");
src/libaudqt/file-entry.cc: dialog->setWindowRole("file-dialog");
src/libaudqt/log-inspector.cc: setWindowRole("log-inspector");
src/libaudqt/queue-manager-qt.cc: setWindowRole("queue-manager");
src/libaudqt/eq-preset-qt.cc: dialog->setWindowRole("file-dialog");
src/libaudqt/eq-preset-qt.cc: dialog->setWindowRole("file-dialog");
src/libaudqt/prefs-plugin.cc: cw->root->setWindowRole("plugin-settings");
src/libaudqt/fileopener.cc: dialog->setWindowRole("file-dialog");
src/libaudqt/playlist-management.cc: dialog->setWindowRole("rename-playlist");
src/libaudqt/playlist-management.cc: dialog->setWindowRole("remove-playlist");
src/ui-common/dialogs-qt.cc: m_progress->setWindowRole ("progress");
src/skins-qt/equalizer.cc: equalizerwin->setWindowRole ("equalizer");
src/skins-qt/plugin-window.cc: setWindowRole ("plugin");
src/skins-qt/main.cc: mainwin->setWindowRole("mainwindow");
src/skins-qt/playlistwin.cc: playlistwin->setWindowRole ("playlist");
src/skins-qt/search-select.cc: setWindowRole ("search");
src/qtui/main_window.cc: setWindowRole("plugin");
src/qtui/main_window.cc: setWindowRole("mainwindow");
src/delete-files/delete-files.cc: qdialog->setWindowRole ("message"); |
|
Great question, it appears this bug exists in core Your specific example actually does NOT crash on my particular environment as explained below, since native widget concurrent restore_toplevel(dup-role)=2 error 1: the specified toplevel id is already used
native widget sequential restore_toplevel(dup-role)=2 ok
native widget reshow restore_toplevel(dup-role)=2 ok
native file concurrent restore_toplevel(dup-role)=0 ok
native file sequential restore_toplevel(dup-role)=0 ok
native file reshow restore_toplevel(dup-role)=0 ok
native msg concurrent restore_toplevel(dup-role)=0 ok
native msg sequential restore_toplevel(dup-role)=0 ok
native msg reshow restore_toplevel(dup-role)=0 ok
nonative widget concurrent restore_toplevel(dup-role)=2 error 1: the specified toplevel id is already used
nonative widget sequential restore_toplevel(dup-role)=2 ok
nonative widget reshow restore_toplevel(dup-role)=2 ok
nonative file concurrent restore_toplevel(dup-role)=2 error 1: the specified toplevel id is already used
nonative file sequential restore_toplevel(dup-role)=2 ok
nonative file reshow restore_toplevel(dup-role)=2 ok
nonative msg concurrent restore_toplevel(dup-role)=2 error 1: the specified toplevel id is already used
nonative msg sequential restore_toplevel(dup-role)=2 ok
nonative msg reshow restore_toplevel(dup-role)=2 okFor cases it appears roles KWin will free the toplevel ID if it was already used, if it's being opened after the window that had the role is already destroyed. Hiding a window and bringing it back doesn't cause a problem. For my setup, for If I set I will also draft fixes under the core repo for @radioactiveman would like your input for the shorter lived Also, the fixes in this PR itself as it stands do not cause additional issues with any of the above, ie this change does not conflict with the core repo's
They do share the same wayland session namespace but I did not find anything in core that would collide with anything from plugins. If someone made a plugin called PR open for the core repo addressing it: audacious-media-player/audacious#1889 Rather than the smaller changes for plugins due to only needing changes in 2 locations for https://github.com/audacious-media-player/audacious-plugins/, and in the interest of avoiding inconsistency/confusion as to why some are using a similar but different method of setting the role, all 16 instances of setWindowRole under the core repo are now run through a helper in libaudqt-internal.h that is then included throughout the various cases that use it, if necessary. dialog->setWindowRole("foo");becomes set_window_role(dialog, "foo");throughout. |
- Make roles more unique - Remove generic role names - Adapt GTK code as well - Set missing role names
6993dd5
into
audacious-media-player:master
Thinking about that I decided to just drop the roles for such windows. The benefit for those short-lived dialogs is from my point of view indeed very limited. |
Completely valid conclusion. Glad to have helped! Been using audacious as my preferred foobar2000 analogue on linux after leaving windows, and working on this was a bit of a crash course in wayland/X11/Qt interaction for me, so thanks! Will report back if I find any issues, but I've been using a build with this fix for a bit and haven't had issues to date so I'm sure it'll be all good to go. |
Full writeup is in audacious-media-player/audacious#1887 but restating some info (not that this is complex in any way, i just ramble):
This fixes a crash with qt 6.12.0 on kwin 6.7.5 due to
WM_WINDOW_ROLEcollisions.Plugin windows all shared the window role
plugin. Qt 6.12.0 now passes the role to xdg_session_v1 as the toplevel ID.WM_WINDOW_ROLEis expected to be unique rather than shared among all nontransient child windows. kwin enforces this uniqueness and terminates the client on duplicates.My change makes the role
plugin-<id>on all platforms which follows existing X11 convention (source) while fixing the new crash. It appears the ICCCM convention was not strictly enforced (hence no prior issues with this), but according to ICCCM 5.1, technically thepluginshared role is unexpected behavior, and this fixes that.user created window rules that exactly match
pluginwill need to be updated to use the prefix.This is quite simple, we just make the role unique per plugin, which can be done via the dock item ID as is already done for
setObjectName()inDockWidget:I've simply updated to mimic that within
src/qtui/main_window.ccandsrc/skins-qt/plugin-window.cc:becomes
For whatever reasons,
src/qtui/main_window.ccand src/skins-qt/plugin-window.ccuse different spacing conventions so that's why they differ in that, but otherwise it's the same change on each.