tst_qabstractitemview: add debug code for crash in testDialogAsEditor()

Now when the editor gets closed unexpectely we should get a proper
backtrace to see why.

Task-number: QTBUG-136653
Change-Id: I96fb8f2260cdb6e7e6a48ad15ac35598ad9266d5
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Liang Qi <liang.qi@qt.io>
This commit is contained in:
Christian Ehrlicher 2025-05-23 22:15:33 +02:00 committed by Liang Qi
parent 516ffe8275
commit 58215a1821
1 changed files with 12 additions and 0 deletions

View File

@ -2301,6 +2301,16 @@ void tst_QAbstractItemView::testDialogAsEditor()
{
DialogItemDelegate delegate;
bool canBeDestroyed = true;
connect(&delegate, &QAbstractItemDelegate::closeEditor,
this, [&](QWidget *editor, QAbstractItemDelegate::EndEditHint) {
// if we get here but we are not yet in the state to
// get destroyed, abort to trigger backtrace so we see
// why we get here
if (!canBeDestroyed)
qFatal("Please report the following backtrace on QTBUG-136653");
});
QStandardItemModel model;
model.appendRow(new QStandardItem(QStringLiteral("editme")));
@ -2319,8 +2329,10 @@ void tst_QAbstractItemView::testDialogAsEditor()
QCOMPARE(delegate.result, QDialog::Rejected);
canBeDestroyed = false;
view.edit(model.index(0,0));
canBeDestroyed = true;
QVERIFY(QTest::qWaitForWindowExposed(delegate.openedEditor));
delegate.openedEditor->accept();