Bug 480652 - Regression when closing/hiding the main window
Summary: Regression when closing/hiding the main window
Status: RESOLVED UPSTREAM
Alias: None
Product: kwin
Classification: Plasma
Component: general (show other bugs)
Version: master
Platform: Neon Linux
: NOR major
Target Milestone: ---
Assignee: KWin default assignee
URL: https://bugreports.qt.io/browse/QTBUG...
Keywords: qt6
Depends on:
Blocks:
 
Reported: 2024-02-01 06:09 UTC by Alexander Reinholdt
Modified: 2024-02-04 16:45 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Wayland debug output (80.93 KB, text/plain)
2024-02-01 17:48 UTC, Alexander Reinholdt
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Reinholdt 2024-02-01 06:09:38 UTC
Hello,

I am the developer of Smb4K and I am currently testing my application under Plasma 6 / KWin 6 on KDE neon unstable. I found some regressions compared to Plasma 5 / KWin 5 regarding the closing of the main window. I use KWin with Wayland, the default on KDE neon unstable.

SUMMARY

There are two things that do not work as expected anymore and which worked fine before:

(1) Closing the main window through the close button of the window. This should result in hiding the main window to the system tray.
(2) Closing the main window through the Quit action. This should result in exiting the application.

The main window has a queryClose() function that currently looks like this:

bool Smb4KMainWindow::queryClose()
{
    if (!m_quitting && !qApp->isSavingSession() && isVisible()) {
        // This part has been copied from JuK application.
        KMessageBox::information(this,
                                 i18n("<qt>Closing the main window will keep Smb4K running in the system tray.<br>"
                                      "Use <i>Quit</i> from the <i>File</i> menu to quit the application.</qt>"),
                                 i18n("Docking"),
                                 QStringLiteral("DockToSystemTrayInfo"));
        setVisible(false);
        return false;
    }

    return true;
}

There is also a slot connected to the Quit action:

void Smb4KMainWindow::slotQuit()
{
    m_quitting = true;
    // saveSettings();
    close();
    QCoreApplication::quit();
} 

Regression 1:
When queryClose() is called and the application is not supposed to be exited, it returns false as it should in that case. However, after the message box is shown, the main window won't hide. That worked under KWin 5 perfectly.

Regression 2:
When queryClose() is called through the Quit action, the main window will eventually be closed, but Smb4K is still running and seem to enter an infinite loop. When running Smb4K in gdb and killing it when it is in the loop, I get this output:

Thread 1 "smb4k" received signal SIGINT, Interrupt.
0x00007ffff73e9934 in QApplication::topLevelWidgets() () from /lib/x86_64-linux-gnu/libQt6Widgets.so.6

I am not that familiar with gdb. If I can provide more info using it, please give me a hint.

STEPS TO REPRODUCE
Try to quit Smb4K (from master) using either the "Close" button of the main window (triggering Regression 1) or the "Quit" action (triggering Regression 2).

OBSERVED RESULT
The main window does not hide (Regression 1) or does not exit, but instead enters an infinite loop (Regression 2).

EXPECTED RESULT
The main window either hides or the application exits.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: KDE neon Unstable Edition (updated 01-02-2024)
(available in About System)
KDE Plasma Version: 6.0.80
KDE Frameworks Version: 5.249
Qt Version: 6.6.1

ADDITIONAL INFORMATION
Graphics platform is Wayland.
Comment 1 Vlad Zahorodnii 2024-02-01 10:34:49 UTC
: && /usr/bin/clang++ -pipe -fno-operator-names -fno-exceptions -Wno-gnu-zero-variadic-macro-arguments -Wall -Wextra -Wcast-align -Wchar-subscripts -Wformat-security -Wno-long-long -Wpointer-arith -Wundef -Wnon-virtual-dtor -Woverloaded-virtual -Werror=return-type -Werror=init-self -Werror=undef -Wvla -Wdate-time -pedantic -Wzero-as-null-pointer-constant -fdiagnostics-color=always -g -Wl,--enable-new-dtags helpers/CMakeFiles/mounthelper.dir/mounthelper_autogen/mocs_compilation.cpp.o helpers/CMakeFiles/mounthelper.dir/smb4kmounthelper.cpp.o -o bin/mounthelper  -Wl,-rpath,/data/projects/kde/build/extragear/network/smb4k/bin:/data/projects/kde/usr/lib:  bin/libsmb4kcore.so  /usr/lib/libQt6PrintSupport.so.6.7.0  /data/projects/kde/usr/lib/libKF6KIOWidgets.so.6.0.0  /data/projects/kde/usr/lib/libKF6KIOGui.so.6.0.0  /data/projects/kde/usr/lib/libKF6KIOCore.so.6.0.0  /data/projects/kde/usr/lib/libKF6AuthCore.so.6.0.0  /data/projects/kde/usr/lib/libKF6Solid.so.6.0.0  /data/projects/kde/usr/lib/libKF6Service.so.6.0.0  /data/projects/kde/usr/lib/libKF6Completion.so.6.0.0  /data/projects/kde/usr/lib/libKF6IconThemes.so.6.0.0  /data/projects/kde/usr/lib/libKF6I18n.so.6.0.0  /data/projects/kde/usr/lib/libKF6ConfigGui.so.6.0.0  /data/projects/kde/usr/lib/libKF6JobWidgets.so.6.0.0  /data/projects/kde/usr/lib/libKF6CoreAddons.so.6.0.0  /data/projects/kde/usr/lib/libKF6Notifications.so.6.0.0  /data/projects/kde/usr/lib/libKF6WidgetsAddons.so.6.0.0  /data/projects/kde/usr/lib/libKF6Wallet.so.6.0.0  /usr/lib/libQt6Widgets.so.6.7.0  /data/projects/kde/usr/lib/libKF6ConfigCore.so.6.0.0  /usr/lib/libQt6Gui.so.6.7.0  /usr/lib/libGLX.so  /usr/lib/libOpenGL.so  /data/projects/kde/usr/lib/libKF6DNSSD.so.6.0.0  /usr/lib/libQt6Network.so.6.7.0  /usr/lib/libQt6DBus.so.6.7.0  /usr/lib/libQt6Core.so.6.7.0  /usr/lib/libsmbclient.so  -Wl,-rpath-link,/data/projects/kde/usr/lib && :
/usr/bin/ld: helpers/CMakeFiles/mounthelper.dir/smb4kmounthelper.cpp.o: in function `Smb4KMountHelper::mount(QMap<QString, QVariant> const&)':
/data/projects/kde/src/extragear/network/smb4k/helpers/smb4kmounthelper.cpp:56:(.text+0x25f): undefined reference to `Smb4KGlobal::findMountExecutable()'
/usr/bin/ld: /data/projects/kde/src/extragear/network/smb4k/helpers/smb4kmounthelper.cpp:126:(.text+0xd5d): undefined reference to `Smb4KGlobal::wait(int)'
/usr/bin/ld: helpers/CMakeFiles/mounthelper.dir/smb4kmounthelper.cpp.o: in function `Smb4KMountHelper::unmount(QMap<QString, QVariant> const&)':
/data/projects/kde/src/extragear/network/smb4k/helpers/smb4kmounthelper.cpp:148:(.text+0xfc0): undefined reference to `Smb4KGlobal::findUmountExecutable()'
/usr/bin/ld: /data/projects/kde/src/extragear/network/smb4k/helpers/smb4kmounthelper.cpp:232:(.text+0x1b50): undefined reference to `Smb4KGlobal::wait(int)'
/usr/bin/ld: bin/mounthelper: protected symbol `_ZN11Smb4KGlobal4waitEi' isn't defined
/usr/bin/ld: final link failed: bad value

smb4k fails to build on my machine, so I can't test it
Comment 2 Vlad Zahorodnii 2024-02-01 10:37:22 UTC
Regression 1:
When queryClose() is called and the application is not supposed to be exited, it returns false as it should in that case. However, after the message box is shown, the main window won't hide. That worked under KWin 5 perfectly.

Can you run smb4k as follows

  WAYLAND_DEBUG=1 smb4k > log.txt 2>&1

click the close button in the window decoration to reproduce the first regression and then attach log.txt file to this bug report?
Comment 3 Nicolas Fella 2024-02-01 12:09:45 UTC
This sounds like https://bugs.kde.org/show_bug.cgi?id=478734, i.e. a Qt/Application bug, not a KWin or Wayland bug
Comment 4 Alexander Reinholdt 2024-02-01 17:48:42 UTC
Created attachment 165446 [details]
Wayland debug output

This is the requested debug output. Smb4K started docked to the system tray, i.e. the main window was hidden. I restored it and pressed the close button. After that I killed Smb4K with CTRL+C in the terminal (regression 2 is still there).
Comment 5 Vlad Zahorodnii 2024-02-02 08:18:46 UTC
[2268087.545] xdg_toplevel@46.close()
Smb4KMainWindow::queryClose()
[2268121.897]  -> wl_compositor@4.create_surface(new id wl_surface@57)
[2268121.966]  -> org_kde_kwin_appmenu_manager@41.create(new id org_kde_kwin_appmenu@60, wl_surface@57)
[2268122.233]  -> wl_compositor@4.create_region(new id wl_region@61)
[2268122.254]  -> wl_region@61.add(0, 0, 733, 168)
[2268122.266]  -> wl_surface@57.set_opaque_region(wl_region@61)
[2268122.274]  -> wl_region@61.destroy()
[2268122.294]  -> wl_compositor@4.create_region(new id wl_region@62)
[2268122.304]  -> wl_region@62.add(0, 0, 723, 158)
[2268122.313]  -> wl_surface@57.set_opaque_region(wl_region@62)
[2268122.321]  -> wl_region@62.destroy()
[2268122.545]  -> wp_fractional_scale_manager_v1@7.get_fractional_scale(new id wp_fractional_scale_v1@63, wl_surface@57)
[2268122.568]  -> xdg_wm_base@3.get_xdg_surface(new id xdg_surface@64, wl_surface@57)
[2268122.584]  -> xdg_surface@64.get_toplevel(new id xdg_toplevel@65)
[2268122.594]  -> zxdg_decoration_manager_v1@34.get_toplevel_decoration(new id zxdg_toplevel_decoration_v1@66, xdg_toplevel@65)
[2268122.603]  -> zxdg_toplevel_decoration_v1@66.unset_mode()
[2268122.611]  -> xdg_toplevel@65.set_parent(xdg_toplevel@46)
[2268122.620]  -> xdg_toplevel@65.set_min_size(723, 158)
[2268122.628]  -> xdg_toplevel@65.set_max_size(723, 158)
[2268122.641]  -> xdg_toplevel@65.set_title("Andocken — Smb4K")
[2268122.651]  -> xdg_toplevel@65.set_app_id("org.kde.smb4k")
[2268122.661]  -> wp_viewporter@6.get_viewport(new id wp_viewport@67, wl_surface@57)
[2268122.671]  -> wp_viewport@67.set_destination(723, 158)
[2268122.680]  -> zxdg_toplevel_decoration_v1@66.unset_mode()
[2268122.692]  -> wp_viewport@67.set_destination(723, 158)
[2268122.702]  -> wl_surface@57.set_buffer_transform(0)
[2268122.711]  -> wl_surface@57.commit()
[2268122.720]  -> wp_viewport@67.set_destination(723, 158)
[2268122.756]  -> zwp_text_input_v2@23.update_state(9586, 0)

kwin asks to close the main window, a dialog is created (judging by set_parent), but the main window is not destroyed. Yeah, it looks quite similar to https://bugreports.qt.io/browse/QTBUG-120316, so let's move the issue upstream.
Comment 6 Alexander Reinholdt 2024-02-02 16:07:37 UTC
Just for my information: Is the second regression then also connected with that issue in Qt?
Comment 7 Vlad Zahorodnii 2024-02-02 17:21:21 UTC
I don't know, but it looks like a Qt issue if you're certain that smb4k is correct.
Comment 8 Alexander Reinholdt 2024-02-04 16:45:48 UTC
Okay, thanks!