summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp')
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp100
1 files changed, 100 insertions, 0 deletions
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index f3f63b2067..2a5e59f825 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -396,6 +396,8 @@ private slots:
void touchEventSynthesizedMouseEvent();
void styleSheetPropagation();
+
+ void destroyedSignal();
private:
bool ensureScreenSize(int width, int height);
QWidget *testWidget;
@@ -9592,6 +9594,104 @@ void tst_QWidget::styleSheetPropagation()
}
}
+class DestroyTester : public QObject
+{
+ Q_OBJECT
+public:
+ DestroyTester(QObject *parent) : QObject(parent) { parentDestroyed = 0; }
+ static int parentDestroyed;
+public slots:
+ void parentDestroyedSlot() {
+ ++parentDestroyed;
+ }
+};
+
+int DestroyTester::parentDestroyed = 0;
+
+void tst_QWidget::destroyedSignal()
+{
+ {
+ QWidget *w = new QWidget;
+ DestroyTester *t = new DestroyTester(w);
+ connect(w, SIGNAL(destroyed()), t, SLOT(parentDestroyedSlot()));
+ QCOMPARE(DestroyTester::parentDestroyed, 0);
+ delete w;
+ QCOMPARE(DestroyTester::parentDestroyed, 1);
+ }
+
+ {
+ QWidget *w = new QWidget;
+ DestroyTester *t = new DestroyTester(w);
+ connect(w, SIGNAL(destroyed()), t, SLOT(parentDestroyedSlot()));
+ w->blockSignals(true);
+ QCOMPARE(DestroyTester::parentDestroyed, 0);
+ delete w;
+ QCOMPARE(DestroyTester::parentDestroyed, 1);
+ }
+
+ {
+ QObject *o = new QWidget;
+ DestroyTester *t = new DestroyTester(o);
+ connect(o, SIGNAL(destroyed()), t, SLOT(parentDestroyedSlot()));
+ QCOMPARE(DestroyTester::parentDestroyed, 0);
+ delete o;
+ QCOMPARE(DestroyTester::parentDestroyed, 1);
+ }
+
+ {
+ QObject *o = new QWidget;
+ DestroyTester *t = new DestroyTester(o);
+ connect(o, SIGNAL(destroyed()), t, SLOT(parentDestroyedSlot()));
+ o->blockSignals(true);
+ QCOMPARE(DestroyTester::parentDestroyed, 0);
+ delete o;
+ QCOMPARE(DestroyTester::parentDestroyed, 1);
+ }
+
+ {
+ QWidget *w = new QWidget;
+ DestroyTester *t = new DestroyTester(0);
+ connect(w, SIGNAL(destroyed()), t, SLOT(parentDestroyedSlot()));
+ QCOMPARE(DestroyTester::parentDestroyed, 0);
+ delete w;
+ QCOMPARE(DestroyTester::parentDestroyed, 1);
+ delete t;
+ }
+
+ {
+ QWidget *w = new QWidget;
+ DestroyTester *t = new DestroyTester(0);
+ connect(w, SIGNAL(destroyed()), t, SLOT(parentDestroyedSlot()));
+ w->blockSignals(true);
+ QCOMPARE(DestroyTester::parentDestroyed, 0);
+ delete w;
+ QCOMPARE(DestroyTester::parentDestroyed, 1);
+ delete t;
+ }
+
+ {
+ QObject *o = new QWidget;
+ DestroyTester *t = new DestroyTester(0);
+ connect(o, SIGNAL(destroyed()), t, SLOT(parentDestroyedSlot()));
+ QCOMPARE(DestroyTester::parentDestroyed, 0);
+ delete o;
+ QCOMPARE(DestroyTester::parentDestroyed, 1);
+ delete t;
+ }
+
+ {
+ QObject *o = new QWidget;
+ DestroyTester *t = new DestroyTester(0);
+ connect(o, SIGNAL(destroyed()), t, SLOT(parentDestroyedSlot()));
+ o->blockSignals(true);
+ QCOMPARE(DestroyTester::parentDestroyed, 0);
+ delete o;
+ QCOMPARE(DestroyTester::parentDestroyed, 1);
+ delete t;
+ }
+
+}
+
#ifndef QTEST_NO_CURSOR
void tst_QWidget::underMouse()
{