Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Segfault when adding QMainWindow subclass to QMdiArea.
I've believe I've found a reliable segfault under the following conditions:
- building against Qt5.9.1 installed from the Kubuntu-Artful repositories
- compiling with clang5 in c++14 mode
- adding a subclass of QMainWindow to a QMdiArea and showing it
- the subclass of QMainWindow uses a .ui file for its interface
This segfault does not occur when building against Qt5.9.2 installed using the Qt-provided installer (i.e. the MaintenanceTool) on the same system. I've created a small example project here on GitHub that demonstrates the issue.
First question, I suppose, is "is adding a QMainWindow to a QMdiArea a legitimate thing to do?" I think it is, but I get that it might be a bit of a niche case.
Second question is "where should I report this?" My feeling is the Kubuntu Qt packagers but I'd appreciate some advice. Also, if anyone can (dis)confirm the existence of this issue I'd appreciate it so that I can rule out it being a peculiarity of my particular system.
VRonin last edited by VRonin
Could not replicate on Qt 5.9.2 64bit MSVC2013 Windows
Could you pinpoint the place (method, line) where the segfault occurs?
is adding a QMainWindow to a QMdiArea a legitimate thing to do?
where should I report this?
https://bugreports.qt.io but since the bug is gone in Qt 5.9.2 I don't see what more can they do
Thanks for investigating. The segfault is in QWindow::winId(). Stack trace follows:
QWindow::winId() const ?? ?? ?? QMenuBar::eventFilter(QObject *, QEvent *) QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject *, QEvent *) QApplicationPrivate::notify_helper(QObject *, QEvent *) QApplication::notify(QObject *, QEvent *) QCoreApplication::notifyInternal2(QObject *, QEvent *) QWidget::setParent(QWidget *, QFlags<Qt::WindowType>) QLayout::addChildWidget(QWidget *) QLayout::addWidget(QWidget *) QMdiSubWindow::setWidget(QWidget *) QMdiArea::addSubWindow(QWidget *, QFlags<Qt::WindowType>) MainWindow::MainWindow(QWidget *)::$_0::operator()() const [mainwindow.cpp:15] QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, MainWindow::MainWindow(QWidget *)::$_0>::call(MainWindow::MainWindow(QWidget *)::$_0&, void * *) [qobjectdefs_impl.h:130] QtPrivate::Functor<MainWindow::MainWindow(QWidget *)::$_0, 0>::call<QtPrivate::List<>, void>(MainWindow::MainWindow(QWidget *)::$_0&, void *, void * *) [qobjectdefs_impl.h:240] QtPrivate::QFunctorSlotObject<MainWindow::MainWindow(QWidget *)::$_0, 0, QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase *, QObject *, void * *, bool *) [qobject_impl.h:168] QMetaObject::activate(QObject *, int, int, void * *) QAction::triggered(bool)
OK. So I've tracked down the issue a bit further. In the stack trace above, those "??" calls toward the top are in the KDEPlasmaPlatformTheme.so shared library, and this coupled with the fact that these are being called from within QMenuBar made me think that perhaps it's the Plasma "Global Menu" widget that's triggering the problem. And so it seems. So the issue is repeatable in the following circumstances:
- running on KDE Plasma
- having one (or more) Global Menu widgets in a panel or on the desktop
- having the setting "Application Style/Fine Tuning/Menubar Style" set to "Application Menu widget" in the KDE System Settings application.
- The QMainWindow being added to the MDI area has a menu bar.
My conclusion, therefore, is that I need to report this as an issue for KDE Plasma.