letsfindaway / OpenBoard

I'm using this fork to contribute features and fixes to the upstream project. In order to create good pull requests, I'm rebasing my feature branches, squashing and reordering commits, etc. If you fork this repository be aware that my development branches may rewrite history without prior notice.
http://openboard.ch/
GNU General Public License v3.0
9 stars 0 forks source link

Crash when editing display configuration on Windows #108

Closed letsfindaway closed 2 years ago

letsfindaway commented 2 years ago

A new issue appeared only on Windows. A click on the line edit makes the app crash. Display management in the preferences cannot be tested.

Tested on Qt 5.15.0 and Qt 6.4.0. Don't know where it comes from, as I remember well having tested this on Windows with no crash.

I'll try to give more info on the crash, but seems to happen deeply in Qt.

Originally posted by @kaamui in https://github.com/letsfindaway/OpenBoard/issues/74#issuecomment-1285674825

kaamui commented 2 years ago

I just have no idea what is going on here. Here's the stack trace (in case you see something I don't) :

1  std::unique_ptr<QWExtra,std::default_delete<QWExtra>>::operator bool memory                          1898 0x7ffe6ba34a3e 
2  QWidgetPrivate::maybeTopData                                         qwidget_p.h                     819  0x7ffe6ba3dcda 
3  QWidgetPrivate::windowHandle                                         qwidget.cpp                     1085 0x7ffe6bab7485 
4  QWidget::windowHandle                                                qwidget.cpp                     2486 0x7ffe6bab21f4 
5  QApplicationPrivate::notifyActiveWindowChange                        qapplication.cpp                2089 0x7ffe6ba500e1 
6  QGuiApplicationPrivate::processActivatedEvent                        qguiapplication.cpp             2449 0x7ffe6aa2d69d 
7  QGuiApplicationPrivate::processWindowSystemEvent                     qguiapplication.cpp             1968 0x7ffe6aa2dab4 
8  QWindowSystemInterface::sendWindowSystemEvents                       qwindowsysteminterface.cpp      1181 0x7ffe6a9f7d92 
9  QWindowsGuiEventDispatcher::sendPostedEvents                         qwindowsguieventdispatcher.cpp  82   0x7ffe683ca2f2 
10 QEventDispatcherWin32::processEvents                                 qeventdispatcher_win.cpp        527  0x7ffe6a23e9b2 
11 QWindowsGuiEventDispatcher::processEvents                            qwindowsguieventdispatcher.cpp  73   0x7ffe683ca2a4 
12 QEventLoop::processEvents                                            qeventloop.cpp                  140  0x7ffe6a1657db 
13 QEventLoop::exec                                                     qeventloop.cpp                  232  0x7ffe6a165a44 
14 QDialog::exec                                                        qdialog.cpp                     602  0x7ffe6be2ec4f 
15 UBPreferencesController::show                                        UBPreferencesController.cpp     151  0x7ff7fb90798e 
16 UBPreferencesController::qt_static_metacall                          moc_UBPreferencesController.cpp 204  0x7ff7fbbe35f1 
17 doActivate<0>                                                        qobject.cpp                     3901 0x7ffe6a1dd99f 
18 QMetaObject::activate                                                qobject.cpp                     3947 0x7ffe6a1ca1b7 
19 QAction::triggered                                                   moc_qaction.cpp                 377  0x7ffe6ba27d42 
20 QAction::activate                                                    qaction.cpp                     1162 0x7ffe6ba27059 
21 QMenuPrivate::activateCausedStack                                    qmenu.cpp                       1355 0x7ffe6bd45b13 
22 QMenuPrivate::activateAction                                         qmenu.cpp                       1433 0x7ffe6bd459f4 
23 QMenu::mouseReleaseEvent                                             qmenu.cpp                       2928 0x7ffe6bd3aa00 
24 QWidget::event                                                       qwidget.cpp                     8654 0x7ffe6bab261f 
25 QMenu::event                                                         qmenu.cpp                       3050 0x7ffe6bd3d199 
26 QApplicationPrivate::notify_helper                                   qapplication.cpp                3671 0x7ffe6ba51987 
27 QApplication::notify                                                 qapplication.cpp                3115 0x7ffe6ba4c434 
28 QCoreApplication::notifyInternal2                                    qcoreapplication.cpp            1061 0x7ffe6a16ae9f 
29 QCoreApplication::sendSpontaneousEvent                               qcoreapplication.cpp            1469 0x7ffe6a16ad3b 
30 QApplicationPrivate::sendMouseEvent                                  qapplication.cpp                2603 0x7ffe6ba54182 
31 QWidgetWindow::handleMouseEvent                                      qwidgetwindow.cpp               575  0x7ffe6bb03676 
32 QWidgetWindow::event                                                 qwidgetwindow.cpp               296  0x7ffe6bb024d1 
33 QApplicationPrivate::notify_helper                                   qapplication.cpp                3671 0x7ffe6ba51987 
34 QApplication::notify                                                 qapplication.cpp                3011 0x7ffe6ba4bb47 
35 QCoreApplication::notifyInternal2                                    qcoreapplication.cpp            1061 0x7ffe6a16ae9f 
36 QCoreApplication::sendSpontaneousEvent                               qcoreapplication.cpp            1469 0x7ffe6a16ad3b 
37 QGuiApplicationPrivate::processMouseEvent                            qguiapplication.cpp             2215 0x7ffe6aa2a514 
38 QGuiApplicationPrivate::processWindowSystemEvent                     qguiapplication.cpp             1947 0x7ffe6aa2da36 
39 QWindowSystemInterface::sendWindowSystemEvents                       qwindowsysteminterface.cpp      1181 0x7ffe6a9f7d92 
40 QWindowsGuiEventDispatcher::sendPostedEvents                         qwindowsguieventdispatcher.cpp  82   0x7ffe683ca2f2 
41 QEventDispatcherWin32::processEvents                                 qeventdispatcher_win.cpp        527  0x7ffe6a23e9b2 
42 QWindowsGuiEventDispatcher::processEvents                            qwindowsguieventdispatcher.cpp  73   0x7ffe683ca2a4 
43 QEventLoop::processEvents                                            qeventloop.cpp                  140  0x7ffe6a1657db 
44 QEventLoop::exec                                                     qeventloop.cpp                  232  0x7ffe6a165a44 
45 QMenuPrivate::exec                                                   qmenu.cpp                       2661 0x7ffe6bd426b0 
46 QToolButtonPrivate::popupTimerDone                                   qtoolbutton.cpp                 810  0x7ffe6bdfc2ce 
47 QToolButton::showMenu                                                qtoolbutton.cpp                 706  0x7ffe6bdfa89c 
48 QToolButtonPrivate::_q_buttonPressed                                 qtoolbutton.cpp                 719  0x7ffe6bdfbd3f 
49 QToolButton::qt_static_metacall                                      moc_qtoolbutton.cpp             138  0x7ffe6bdf9c38 
50 doActivate<0>                                                        qobject.cpp                     3901 0x7ffe6a1dd99f 
51 QMetaObject::activate                                                qobject.cpp                     3947 0x7ffe6a1ca1b7 
52 QAbstractButton::pressed                                             moc_qabstractbutton.cpp         296  0x7ffe6bc2e191 
53 QAbstractButtonPrivate::emitPressed                                  qabstractbutton.cpp             439  0x7ffe6bc301b1 
54 QAbstractButton::mousePressEvent                                     qabstractbutton.cpp             1017 0x7ffe6bc2e8f4 
55 QToolButton::mousePressEvent                                         qtoolbutton.cpp                 614  0x7ffe6bdfaedf 
56 QWidget::event                                                       qwidget.cpp                     8650 0x7ffe6bab25e9 
57 QAbstractButton::event                                               qabstractbutton.cpp             1002 0x7ffe6bc2e462 
58 QToolButton::event                                                   qtoolbutton.cpp                 1012 0x7ffe6bdfad74 
59 QApplicationPrivate::notify_helper                                   qapplication.cpp                3671 0x7ffe6ba51987 
60 QApplication::notify                                                 qapplication.cpp                3115 0x7ffe6ba4c434 
61 QCoreApplication::notifyInternal2                                    qcoreapplication.cpp            1061 0x7ffe6a16ae9f 
62 QCoreApplication::sendSpontaneousEvent                               qcoreapplication.cpp            1469 0x7ffe6a16ad3b 
63 QApplicationPrivate::sendMouseEvent                                  qapplication.cpp                2603 0x7ffe6ba54182 
64 QWidgetWindow::handleMouseEvent                                      qwidgetwindow.cpp               677  0x7ffe6bb042e0 
65 QWidgetWindow::event                                                 qwidgetwindow.cpp               296  0x7ffe6bb024d1 
66 QApplicationPrivate::notify_helper                                   qapplication.cpp                3671 0x7ffe6ba51987 
67 QApplication::notify                                                 qapplication.cpp                3011 0x7ffe6ba4bb47 
68 QCoreApplication::notifyInternal2                                    qcoreapplication.cpp            1061 0x7ffe6a16ae9f 
69 QCoreApplication::sendSpontaneousEvent                               qcoreapplication.cpp            1469 0x7ffe6a16ad3b 
70 QGuiApplicationPrivate::processMouseEvent                            qguiapplication.cpp             2215 0x7ffe6aa2a514 
71 QGuiApplicationPrivate::processWindowSystemEvent                     qguiapplication.cpp             1947 0x7ffe6aa2da36 
72 QWindowSystemInterface::sendWindowSystemEvents                       qwindowsysteminterface.cpp      1181 0x7ffe6a9f7d92 
73 QWindowsGuiEventDispatcher::sendPostedEvents                         qwindowsguieventdispatcher.cpp  82   0x7ffe683ca2f2 
74 QEventDispatcherWin32::processEvents                                 qeventdispatcher_win.cpp        527  0x7ffe6a23e9b2 
75 QWindowsGuiEventDispatcher::processEvents                            qwindowsguieventdispatcher.cpp  73   0x7ffe683ca2a4 
76 QEventLoop::processEvents                                            qeventloop.cpp                  140  0x7ffe6a1657db 
77 QEventLoop::exec                                                     qeventloop.cpp                  232  0x7ffe6a165a44 
78 QCoreApplication::exec                                               qcoreapplication.cpp            1369 0x7ffe6a168d09 
79 QGuiApplication::exec                                                qguiapplication.cpp             1868 0x7ffe6aa26388 
80 QApplication::exec                                                   qapplication.cpp                2812 0x7ffe6ba4b45a 
81 UBApplication::exec                                                  UBApplication.cpp               405  0x7ff7fb8c1ea2 
82 main                                                                 main.cpp                        165  0x7ff7fb8bdeb9 
83 WinMain                                                              qtmain_win.cpp                  97   0x7ff7fbe6c755 
84 invoke_main                                                          exe_common.inl                  107  0x7ff7fbda5772 
85 __scrt_common_main_seh                                               exe_common.inl                  288  0x7ff7fbda565e 
86 __scrt_common_main                                                   exe_common.inl                  331  0x7ff7fbda551e 
87 WinMainCRTStartup                                                    exe_winmain.cpp                 17   0x7ff7fbda580e 
88 BaseThreadInitThunk                                                  KERNEL32                             0x7ffefeef7034 
89 RtlUserThreadStart                                                   ntdll                                0x7fff002426a1 
kaamui commented 2 years ago

It seems that focusOutEvent is called right after focusInEvent.

And no more crash if I comment qDeleteAll (but still out of focus so I can't change the input value). So now we just have to find why focusOutEvent is called when it should not, or delay the deletion of the QGraphicsRectItems

Edit : I just remembered that we already faced this issue, where the creation of the QGraphicsRectItems led to focus Out (but with no crash the last time, blinking issues instead). You initially fixed it by adding button->setWindowFlag(Qt::WindowDoesNotAcceptFocus, true);. Maybe another object is gaining focus ?

kaamui commented 2 years ago

I found this => https://bugreports.qt.io/browse/QTBUG-36230

I added the attribute WA_ShowWithoutActivating and it seems to fix the issue. Didn't check on Linux and OSX, but it should be OK I guess.

commit : 69d0deb0

this issue can be closed I think

kaamui commented 2 years ago

Also, is it necessary to create and delete the QGraphicsRectItems every time focus in and out events are triggered ? Could it be possible to just show/hide them, and to add a signal/slot that update the mScreenLabels when a change is made in the hardware ?

letsfindaway commented 2 years ago

Also, is it necessary to create and delete the QGraphicsRectItems every time focus in and out events are triggered ? Could it be possible to just show/hide them, and to add a signal/slot that update the mScreenLabels when a change is made in the hardware ?

Thanks for your work on fixing the DisplayManager! I will have a look on that later.

I'm recreating the QPushButtons (not QGraphicsRectItems) because it might be that a monitor was attached or detached in the meantime so I always have the correct number of labels. Else I would have to adjust the labels as monitors come and go, and this seems to be much more error prone. Performance is not an issue in this situation.

letsfindaway commented 2 years ago

Closing as you suggested.