[Interest] Weird assert, how to debug?

Scott Bloom scott at towel42.com
Fri Mar 3 18:33:17 CET 2023

As you can see by the sample, Im not doing anything special, not changing any ownership, and not doing any individual deletes + deleteLaters with a processEvents (The root cause of many a "double delete in my experience"), so Im really stumped on this one.

Something in designer with the UI file is causing this.


From: Interest <interest-bounces at qt-project.org> On Behalf Of Axel Spoerl via Interest
Sent: Thursday, March 2, 2023 10:09 PM
To: interest at qt-project.org
Subject: Re: [Interest] Weird assert, how to debug?

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<mailto:interest-bounces at qt-project.org>> im Auftrag von Scott Bloom <scott at towel42.com<mailto:scott at towel42.com>>
Gesendet: Freitag, 3. März 2023 01:37
An: interest at qt-project.org<mailto:interest at qt-project.org> <interest at qt-project.org<mailto: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/c8f10a3c/attachment.htm>

More information about the Interest mailing list