summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorRobin Burchell <robin.burchell@collabora.co.uk>2011-05-05 10:49:59 +0200
committerOlivier Goffart <olivier.goffart@nokia.com>2011-05-10 12:54:56 +0200
commit0bb70c316437c2b654ef2fd0555e04a57a6b3620 (patch)
treebdfe8bd23f8b0f9d95924a38a90696455a058a4b /tests/auto
parent202df2ae8914c3424c7a8c84303e70c37e62646d (diff)
Ensure that QDateTimeEdit::calendarWidget() will always return a valid widget.
This case may be triggered in the (admittedly slightly abnormal) case where a user wishes to embed the calendar widget in a layout or, for whatever reason, do something else that will change its ownership. We work around this by detecting when it is deleted and recreating the widget. This will also have a positive side effect if setCalendarWidget() is called with a widget which is then subsequently deleted, returning the default widget instead of a pointer to (now deleted) memory. Reviewed-by: Denis Dzyubenko Merge-request: 2568 Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com> (cherry picked from commit 124ec3200f8453142717fcfe7a4aa0a55164aaa6)
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp
index c8c3b90712..9d0c5f7d22 100644
--- a/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp
+++ b/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp
@@ -275,6 +275,8 @@ private slots:
void focusNextPrevChild();
void taskQTBUG_12384_timeSpecShowTimeOnly();
+
+ void deleteCalendarWidget();
private:
EditorDateEdit* testWidget;
@@ -3438,5 +3440,26 @@ void tst_QDateTimeEdit::taskQTBUG_12384_timeSpecShowTimeOnly()
QCOMPARE(edit.time(), time.time());
}
+void tst_QDateTimeEdit::deleteCalendarWidget()
+{
+ {
+ // setup
+ QCalendarWidget *cw = 0;
+ QDateEdit edit;
+ QVERIFY(!edit.calendarWidget());
+ edit.setCalendarPopup(true);
+ QVERIFY(edit.calendarWidget());
+ edit.calendarWidget()->setObjectName("cw1");;
+
+ // delete
+ cw = edit.calendarWidget();
+ delete cw;
+
+ // it should create a new widget
+ QVERIFY(edit.calendarWidget());
+ QVERIFY(edit.calendarWidget()->objectName() != "cw1");
+ }
+}
+
QTEST_MAIN(tst_QDateTimeEdit)
#include "tst_qdatetimeedit.moc"