[QTBUG-61213] Widget crashes during setAttribute(Qt::WA_WindowPropagation) Created: 03 Jun '17  Updated: 19 Dec '17  Resolved: 19 Dec '17

Status: Closed
Project: Qt
Component/s: Widgets: Widgets and Dialogs
Affects Version/s: 5.9.0
Fix Version/s: 5.9.4

Type: Bug Priority: P1: Critical
Reporter: Gary Holmlund Assignee: Richard Moe Gustavsen
Resolution: Done Votes: 4
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File widgetbug.tar    


The following lines will crash Qt:

QWidget* w = new QWidget(nullptr);


Crashes with Qt 5.9, but not previous versions. Adding a parent to the widget will eliminate the crash. See attached project. 


Comment by Alex [ 30 Jun '17 ]

Same issue.

Comment by Roman Telezhynskyi [ 24 Jul '17 ]

I met the same bug. It still presents in version 5.9.1.

Comment by Arman [ 01 Aug '17 ]

The same behaviour.

Comment by Thomas Sondergaard [ 16 Nov '17 ]

Just upgraded from 5.7.1 and hit this bug. Here is a minimal example:

#include <QApplication>
#include <QWidget>

int main(int argc, char **argv)
    QApplication app(argc, argv);

    QWidget w;


and a stacktrace:

#0  0x00007ffff78fde41 in QWidget::locale() const (this=0x0) at kernel/qwidget.cpp:6009
#1  0x00007ffff7906cad in QWidgetPrivate::resolveLocale() (this=this@entry=0x788bb0) at kernel/qwidget.cpp:6018
#2  0x00007ffff79076e0 in QWidget::setAttribute(Qt::WidgetAttribute, bool) (this=0x7fffffffd910, attribute=<optimized out>, on=true) at kernel/qwidget.cpp:11313
#3  0x0000000000400a1d in main(int, char**) (argc=1, argv=0x7fffffffda58) at example.cc:9

The problem is that in the following code q->parentWidget() returns null:

void QWidgetPrivate::resolveLocale()
    Q_Q(const QWidget);

    if (!q->testAttribute(Qt::WA_SetLocale)) {
        setLocale_helper(q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)
                            ? QLocale()
                            : q->parentWidget()->locale());
Generated at Tue Jan 22 19:55:37 UTC 2019 using Jira 7.11.2#711002-sha1:fdc329dee91471a641faabfe39b5ff8c0a5b3f66.