summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2015-06-03 10:23:56 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-06-03 10:23:56 +0200
commite2f66f921594b7be4af4a058c959557489e86879 (patch)
treecc44931708b57bd5a761906797c7dee0360d1d6b /tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp
parent933bf178aab88ab5df8a68cbf02611d6d8744b1b (diff)
parent754efa57d89c62d1796e01b407e9222e67450f52 (diff)
Merge remote-tracking branch 'origin/5.5' into dev
Conflicts: src/corelib/global/qnamespace.qdoc src/corelib/io/qwindowspipereader.cpp src/corelib/io/qwindowspipereader_p.h src/corelib/statemachine/qstatemachine.cpp src/corelib/statemachine/qstatemachine_p.h src/plugins/platforms/xcb/qxcbconnection.h tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp tests/auto/tools/qmake/tst_qmake.cpp tests/manual/touch/main.cpp Change-Id: I917d694890e79ee3da7d65134b5b085e23e0dd62
Diffstat (limited to 'tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp')
-rw-r--r--tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp
index 9c549365ff..38b473e5ae 100644
--- a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp
+++ b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp
@@ -90,6 +90,7 @@ private slots:
// void buttons();
void testDelete();
+ void testSignalEmissionAfterDelete_QTBUG_45835();
void testRemove();
void testMultipleAdd();
void testStandardButtonMapping_data();
@@ -111,6 +112,7 @@ private:
tst_QDialogButtonBox::tst_QDialogButtonBox()
{
+ qRegisterMetaType<QAbstractButton *>();
}
tst_QDialogButtonBox::~tst_QDialogButtonBox()
@@ -414,6 +416,70 @@ void tst_QDialogButtonBox::testDelete()
QCOMPARE(buttonBox.buttons().count(), 0);
}
+class ObjectDeleter : public QObject
+{
+ Q_OBJECT
+public slots:
+ void deleteButton(QAbstractButton *button)
+ {
+ delete button;
+ }
+
+ void deleteSender()
+ {
+ delete sender();
+ }
+};
+
+void tst_QDialogButtonBox::testSignalEmissionAfterDelete_QTBUG_45835()
+{
+ {
+ QDialogButtonBox buttonBox;
+ QCOMPARE(buttonBox.buttons().count(), 0);
+
+ QSignalSpy buttonClickedSpy(&buttonBox, &QDialogButtonBox::clicked);
+ QVERIFY(buttonClickedSpy.isValid());
+
+ QSignalSpy buttonBoxAcceptedSpy(&buttonBox, &QDialogButtonBox::accepted);
+ QVERIFY(buttonBoxAcceptedSpy.isValid());
+
+ QPushButton *button = buttonBox.addButton("Test", QDialogButtonBox::AcceptRole);
+ QCOMPARE(buttonBox.buttons().count(), 1);
+
+ ObjectDeleter objectDeleter;
+ connect(&buttonBox, &QDialogButtonBox::clicked, &objectDeleter, &ObjectDeleter::deleteButton);
+
+ button->click();
+
+ QCOMPARE(buttonBox.buttons().count(), 0);
+ QCOMPARE(buttonClickedSpy.count(), 1);
+ QCOMPARE(buttonBoxAcceptedSpy.count(), 1);
+ }
+
+ {
+ QPointer<QDialogButtonBox> buttonBox(new QDialogButtonBox);
+ QCOMPARE(buttonBox->buttons().count(), 0);
+
+ QSignalSpy buttonClickedSpy(buttonBox.data(), &QDialogButtonBox::clicked);
+ QVERIFY(buttonClickedSpy.isValid());
+
+ QSignalSpy buttonBoxAcceptedSpy(buttonBox.data(), &QDialogButtonBox::accepted);
+ QVERIFY(buttonBoxAcceptedSpy.isValid());
+
+ QPushButton *button = buttonBox->addButton("Test", QDialogButtonBox::AcceptRole);
+ QCOMPARE(buttonBox->buttons().count(), 1);
+
+ ObjectDeleter objectDeleter;
+ connect(buttonBox.data(), &QDialogButtonBox::clicked, &objectDeleter, &ObjectDeleter::deleteSender);
+
+ button->click();
+
+ QVERIFY(buttonBox.isNull());
+ QCOMPARE(buttonClickedSpy.count(), 1);
+ QCOMPARE(buttonBoxAcceptedSpy.count(), 0);
+ }
+}
+
void tst_QDialogButtonBox::testMultipleAdd()
{
// Add a button into the thing multiple times.