-
-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash when exiting #730
Comments
Hi there!
What you describe here is not really a bug. Since the EditorSettings pane is written in QML and the rest of the app (except the Kanban view) is Qt Widgets, I had to create a new window that will behave like a Popup which leads to some inconsistent behavior you're experiencing. In my new note-taking app (https://get-notes.com/) the editor is written in QML so that problem is gone since the EditorSettings can be part of the QML scene all the time. The ideal solution to this problem would be to convert the editor to QML. Regarding the crash. Can you show a video how to reproduce the crash? At least here on macOS I can't reproduce it. |
Thanks for the quick reply! The screencast is attached below. |
Thanks for the video. I can also reproduce the crash here by just opening Notes' settings window, closing it, and then quitting Notes.
Build options:
|
The crash does not reproduce with the v2.3.1 AppImage (which still uses Qt 6.4.3). Just to rule this out as a problem on our side, I ran Maybe this points to a Qt regression? Unfortunately, the gdb backtrace is obscure to me (this is on 57542f6 btw): ❯ gdb -ex run --args ./build/notes
Reading symbols from ./build/notes...
Starting program: ./build/notes
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7ffff11ff6c0 (LWP 19369)]
[New Thread 0x7ffff09fe6c0 (LWP 19370)]
[New Thread 0x7fffe886b6c0 (LWP 19378)]
[New Thread 0x7fffe13bb6c0 (LWP 19379)]
[New Thread 0x7fffdbfff6c0 (LWP 19380)]
[New Thread 0x7fffdadba6c0 (LWP 19381)]
[New Thread 0x7fffd99be6c0 (LWP 19390)]
[New Thread 0x7fffbf3fe6c0 (LWP 19392)]
[New Thread 0x7fffbebfd6c0 (LWP 19393)]
[New Thread 0x7fffbe3fc6c0 (LWP 19394)]
[New Thread 0x7fffbdbfb6c0 (LWP 19395)]
[New Thread 0x7fffa7fff6c0 (LWP 19396)]
[New Thread 0x7fffa77fe6c0 (LWP 19397)]
[New Thread 0x7fffa6ffd6c0 (LWP 19398)]
[New Thread 0x7fffa67fc6c0 (LWP 19399)]
[New Thread 0x7fffa5ffb6c0 (LWP 19400)]
[New Thread 0x7fffa57fa6c0 (LWP 19403)]
[New Thread 0x7fffa4ff96c0 (LWP 19404)]
[Thread 0x7fffd99be6c0 (LWP 19390) exited]
[Thread 0x7fffdadba6c0 (LWP 19381) exited]
[Thread 0x7fffdbfff6c0 (LWP 19380) exited]
[Thread 0x7fffa57fa6c0 (LWP 19403) exited]
[Thread 0x7fffe13bb6c0 (LWP 19379) exited]
[Thread 0x7fffe886b6c0 (LWP 19378) exited]
Thread 1 "notes" received signal SIGSEGV, Segmentation fault.
QWindow::parent (this=0x0, mode=mode@entry=QWindow::ExcludeTransients) at /usr/src/debug/qt6-base/qtbase/src/gui/kernel/qwindow.cpp:771
771 Q_D(const QWindow);
(gdb) bt
#0 QWindow::parent (this=0x0, mode=mode@entry=QWindow::ExcludeTransients) at /usr/src/debug/qt6-base/qtbase/src/gui/kernel/qwindow.cpp:771
#1 0x00007ffff6f67330 in QWindowContainer::toplevelAboutToBeDestroyed (parent=0x5555570632d0) at /usr/src/debug/qt6-base/qtbase/src/widgets/kernel/qwindowcontainer.cpp:391
#2 0x00007ffff6f37071 in QWidgetPrivate::deleteTLSysExtra (this=0x5555578b19e0) at /usr/src/debug/qt6-base/qtbase/src/widgets/kernel/qwidget.cpp:1709
#3 0x00007ffff6f548a8 in QWidget::destroy (this=0x5555570632d0, destroyWindow=<optimized out>, destroySubWindows=<optimized out>)
at /usr/src/debug/qt6-base/qtbase/src/widgets/kernel/qwidget.cpp:12571
#4 0x00007ffff6ef5b3f in QApplication::~QApplication (this=<optimized out>, this=<optimized out>) at /usr/src/debug/qt6-base/qtbase/src/widgets/kernel/qapplication.cpp:686
#5 0x000055555564dbab in main (argc=1, argv=0x7fffffffdde8) at /home/gui/dev/notes/src/main.cpp:104
(gdb) |
So I found out that this regression(?) was introduced with Qt 6.7.3, and after bisecting qtbase between 6.7.2 (good) and 6.7.3 (bad), I found the culprit commit:
This tiny change prevents the crash on my machine (please test it if you can and report back): diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 186cdbb..496c01d 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1047,7 +1047,7 @@ void MainWindow::setupEditorSettings()
m_editorSettingsQuickView.setResizeMode(QQuickView::SizeViewToRootObject);
m_editorSettingsQuickView.setFlags(Qt::FramelessWindowHint);
m_editorSettingsQuickView.setColor(Qt::transparent);
- m_editorSettingsWidget = QWidget::createWindowContainer(&m_editorSettingsQuickView, nullptr);
+ m_editorSettingsWidget = QWidget::createWindowContainer(&m_editorSettingsQuickView, this);
#if defined(Q_OS_MACOS)
# if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
m_editorSettingsWidget->setWindowFlags(Qt::Popup | Qt::FramelessWindowHint
Though I'm not entirely sure if that's the correct fix. @nuttyartist: Would specifying the main window as the parent of the editor settings widget mess up something on macOS/Windows (visually)? Because on Linux there's no difference, as far as I can tell. |
Can confirm that prevents the crash for me. |
Whoops. @guihkx thanks for the detective work! I forgot why I didn't assign it a parent. I tested now on macOS, it seems to work well. I'll test on Windows and if that works I'll send a PR. |
To be fair, it didn't crash at all before 6.7.3, so it's hardly your fault that it does now... Though there are a couple of other places where you also call |
I believe we always have to set the parent to something, instead of setting it to nullptr. If we don't, the deleter is never called and we either have memory leaks or apparently also crashes like this one. I fixed some of them in this PR: #731 |
Note: this might reference #715.
I've built Notes from source a few minutes ago to give it a run and stumbled upon both a bug and a crash that might be related to it. When I open the settings they are not rendered properly as can be seen below. Furthermore, the window cannot be moved since it closes immediately when clicking anywhere but in content area. Clicking in the area where my mouse is apparently counts as 'in content area' since the window does not close.
So much on the bug.
The crash occours every time when closing the application after the settings window has been used (this might relate to #715).
I have no experience with gdb, all I can provide for now is
Build output (stripped):
Make yields the following warning (stripped absolute path to notes folder):
I run Fedora 41 with GNOME DE (which should provide wayland? cmake found x11 however).
The text was updated successfully, but these errors were encountered: