tst_QMainWindow: fix unit'ed value in AddDockWidget

The constructors didn't initialize all fields, leading the
compiler-generated move contructor to read invalid enum values:

Says UBSan:

  tst_qmainwindow.cpp:1645:8: runtime error: load of value 32675, which is not a valid value for type 'Orientation'
    #0 0x55b1bd283e2e in AddDockWidget::AddDockWidget(AddDockWidget&&) tst_qmainwindow.cpp:1645
    [...]

  tst_qmainwindow.cpp:1645:8: runtime error: load of value 72, which is not a valid value for type 'DockWidgetArea'
    #0 0x55b1bd284024 in AddDockWidget::AddDockWidget(AddDockWidget&&) tst_qmainwindow.cpp:1645
    [...]

(ubsan does not direct uninitialized memory accesses directly).

Fix by vale-initalizing the two members. This is the most natural
initialization for these members: Given that the test passed even with
random data before, 0 is surely good enough.

Amends the start of the public history.

Pick-to: 6.8 6.5 5.15
Change-Id: I6fc0b2f79679fd0f69024066c1e66b4434a5ebe6
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit af71de2036728091b432d7b4284368188961b680)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2025-04-02 09:18:36 +02:00 committed by Qt Cherry-pick Bot
parent 35431fe6e3
commit 53692fc9c5

View File

@ -1657,8 +1657,8 @@ struct AddDockWidget
QString name;
Mode mode;
Qt::Orientation o;
Qt::DockWidgetArea a;
Qt::Orientation o = {};
Qt::DockWidgetArea a = {};
QString other;
void apply(QMainWindow *mw) const;