[Interest] Weird assert, how to debug?

Axel Spoerl axel.spoerl at qt.io
Fri Mar 3 07:09:19 CET 2023

Hi Scott,

I can't make the reproducer crash on Qt 5.15.9 or on the latest dev (6.6).
The assertion happens in QWidget's destructor, when it wants to exit from the focus list.
I can imagine two cases, how this assertion kicks in.

  *   The code path in the if statement right after the assertion has been reached before:
if (d->focus_next != this) {
        d->focus_next->d_func()->focus_prev = d->focus_prev;
        d->focus_prev->d_func()->focus_next = d->focus_next;
        d->focus_next = d->focus_prev = nullptr;
=> An already deleted widget is deleted a second time.

  *   Focus chain has changed without events having been processed, so the destroyed widget doesn't know about it.
Happens in the debugger (e.g. Qt Creator) sometimes, because debugging output is a notirious focus thief.

Option 2 seems more likely to me, since the assertion doesn't shout in release builds.
Updating to the latest Qt Creator version may help. If it doesn't please file a bugreport in https://bugreports.qt.io,
upload the reproducer, specify the Qt and (Qt Creator if used for debugging) versions used.

Von: Interest <interest-bounces at qt-project.org> im Auftrag von Scott Bloom <scott at towel42.com>
Gesendet: Freitag, 3. März 2023 01:37
An: interest at qt-project.org <interest at qt-project.org>
Betreff: [Interest] Weird assert, how to debug?

Im getting an assertion in qwidget.cpp

“d->focus_prev->d_func()->focus_next == this” in Qwidget.cpp line 1443 (Qt 5.15.10)

I realize the response is going to be, create a minimal example, I created a repo on github with it, it’s a simple cmake based project. Any help figuring this out would be appreciated.

The application has a QApplication and a QDialog derived dialog.  The dialog has a tabwidget and a dialogbutton box.

The assertion gets thrown when the dialog is destroyed.


This happens on Windows, I don’t have a linux box setup right now to test on linux.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20230303/76ee180f/attachment.htm>

More information about the Interest mailing list