From a6bd2da2ab62eccae023789899b4f0b6b5e60f74 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 12 Jun 2021 12:40:54 +0200 Subject: [PATCH] QWidgetAction: add test for defaultWidget() being deleted before action ... even though the documentation states that the action takes ownership of the widget. Change-Id: Ie5520fbda295a5a2774ff8b82165070e9d49e310 Reviewed-by: Giuseppe D'Angelo Reviewed-by: Edward Welbourne --- .../kernel/qwidgetaction/tst_qwidgetaction.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp b/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp index 384c07258b..1b43961182 100644 --- a/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp +++ b/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp @@ -74,6 +74,18 @@ void tst_QWidgetAction::cleanup() void tst_QWidgetAction::defaultWidget() { + // check that QWidgetAction deals with the widget being deleted before itself: + { + QToolBar tb1; + + QComboBox combo(&tb1); + + auto action = new QWidgetAction(&tb1); + action->setDefaultWidget(&combo); + + tb1.addAction(action); + } + // check that QWidgetAction takes ownership of the widget: { QToolBar tb1;