summaryrefslogtreecommitdiffstats
path: root/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-11-05 11:59:18 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-11-05 16:47:21 (GMT)
commit7b63ce043dfaec5ec83d938b1cea8ee0ead614ff (patch)
treeed70eb1a750fc69c54a0595c235b5183d59b9ee9 /tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
parent1bfdedb16fdcafc0fdbcea342d68801b8404ea24 (diff)
downloadQt-7b63ce043dfaec5ec83d938b1cea8ee0ead614ff.zip
Qt-7b63ce043dfaec5ec83d938b1cea8ee0ead614ff.tar.gz
Qt-7b63ce043dfaec5ec83d938b1cea8ee0ead614ff.tar.bz2
QStyleSheetStyle: Fix crash that occurs with several instance of QStyleSheetStyle
The problem is that when a widget is destroyed, it was not properly removed from the cache. We connected the destroyed signal to a slot in the QStyleSheetStyle for the first QStyleSheetStyle that handle a widget. but if this QStyleSheetStyle is destroyed, that connection is lost. Solution: Create a new QStyleSheetStyleCaches that will be responsible to clean the caches. This objects is not destroyed as long as there is a QStyleSheetStyle instance, so the connection is not lost. I took the oportunity to move all the caches to this object. Reveiwed-by: Gabriel Task-number: QTBUG-11658
Diffstat (limited to 'tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp')
-rw-r--r--tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
index 04b1e79..9526ad8 100644
--- a/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
+++ b/tests/auto/qstylesheetstyle/tst_qstylesheetstyle.cpp
@@ -103,6 +103,7 @@ private slots:
//at the end because it mess with the style.
void widgetStyle();
void appStyle();
+ void QTBUG11658_cachecrash();
private:
QColor COLOR(const QWidget& w) {
w.ensurePolished();
@@ -1622,6 +1623,37 @@ void tst_QStyleSheetStyle::changeStyleInChangeEvent()
wid.ensurePolished();
}
+void tst_QStyleSheetStyle::QTBUG11658_cachecrash()
+{
+ //should not crash
+ class Widget : public QWidget
+ {
+ public:
+ Widget(QWidget *parent = 0)
+ : QWidget(parent)
+ {
+ QVBoxLayout* pLayout = new QVBoxLayout(this);
+ QCheckBox* pCheckBox = new QCheckBox(this);
+ pLayout->addWidget(pCheckBox);
+ setLayout(pLayout);
+
+ QString szStyleSheet = QLatin1String("* { color: red; }");
+ qApp->setStyleSheet(szStyleSheet);
+ qApp->setStyle(QStyleFactory::create(QLatin1String("Windows")));
+ }
+ };
+
+ Widget *w = new Widget();
+ delete w;
+ w = new Widget();
+ w->show();
+
+ QTest::qWaitForWindowShown(w);
+ delete w;
+ qApp->setStyleSheet(QString());
+}
+
+
QTEST_MAIN(tst_QStyleSheetStyle)
#include "tst_qstylesheetstyle.moc"