Marc Mutz 00ecdd55c6 QErrorMessage: fix UB (invalid cast) in Private::setVisible()
The function can be called from ~QDialog(), in which case a cast of
q_ptr to QErrorMessage is UB.

Says UBSan:

  errormessage.cpp:33:5: runtime error: downcast of address 0x7fff5089a6e0 which does not point to an object of type 'QErrorMessage'
   0x7fff5089a6e0: note: object is of type 'QDialog'
    00 00 00 00  30 74 4e 6a 12 7f 00 00  80 aa 00 00 90 61 00 00  08 76 4e 6a 12 7f 00 00  00 00 e0 1a
                 ^~~~~~~~~~~~~~~~~~~~~~~
                 vptr for 'QDialog'
       #0 0x7f1267ce7d12 in QErrorMessagePrivate::q_func() qerrormessage.cpp:33
       #1 0x7f1267ce7d12 in QErrorMessagePrivate::setVisible(bool) qerrormessage.cpp:410
       #2 0x7f1267caaa25 in QDialog::setVisible(bool) qdialog.cpp:757
       #3 0x7f12654efb28 in QWidget::hide() qwidget.cpp:8179
       #4 0x7f1267caa239 in QDialog::~QDialog() qdialog.cpp:398
       #5 0x7f1267ce72f8 in QErrorMessage::~QErrorMessage() qerrormessage.cpp:287

Fix by casting at most to QDialog* (QWidget* would actually have
sufficed).

Add a code comment.

Amends e0bb9e81ab1a9d71f2893844ea82430467422e21 (I think; it might
have been present in a different form before that).

Pick-to: 6.8 6.5
Change-Id: I61a8692f073c2d2f379ea02fa580f7fe46691c1c
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 0e322aa41984fb8f6259ca8249fdfff6c3ea7e13)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-03-28 16:32:20 +00:00
2025-03-24 18:27:25 +00:00
2024-11-05 14:36:16 +01:00
2015-08-18 19:59:14 +00:00
2024-11-05 14:36:16 +01:00
2025-03-25 08:40:27 +00:00
2024-06-25 11:44:00 +02:00
Description
Qt Base (Core, Gui, Widgets, Network, ...)
822 MiB
Languages
C++ 84.3%
HTML 4.9%
C 3.9%
CMake 3.6%
Objective-C++ 2%
Other 0.8%