summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-06-04 07:30:17 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-06-04 07:59:58 (GMT)
commitcbe3119db5380c41d44d4e936c7da4889c02f147 (patch)
tree255b67f69d28c540235695a87845005902fdff56
parent289c098c15a359c4e5d142a997230db5df554f8d (diff)
downloadQt-cbe3119db5380c41d44d4e936c7da4889c02f147.zip
Qt-cbe3119db5380c41d44d4e936c7da4889c02f147.tar.gz
Qt-cbe3119db5380c41d44d4e936c7da4889c02f147.tar.bz2
BT: Fixes Crash when deleting a QProgressBar which has been styled with QMotifStyle
Same fix as in e9a7e43031d7c1ee712e43be682c4e2c183759c4 but with motif Reported by https://bugs.kde.org/show_bug.cgi?id=193911 Task-number: 255138 Reviewed-by: jbache
-rw-r--r--dist/changes-4.5.23
-rw-r--r--src/gui/styles/qmotifstyle.cpp5
-rw-r--r--tests/auto/qprogressbar/tst_qprogressbar.cpp20
3 files changed, 25 insertions, 3 deletions
diff --git a/dist/changes-4.5.2 b/dist/changes-4.5.2
index 6772405..a54d8ba 100644
--- a/dist/changes-4.5.2
+++ b/dist/changes-4.5.2
@@ -67,6 +67,9 @@ Third party components
* [253339] Don't draw arrows on toolbuttons that have a menu and text only.
* [252301] Ensure that small and mini spin boxes are drawn correctly.
+- QMotifStyle
+ * Fix crash when changing style and destroying progressbar.
+
- QFontDialog
* [252000] Ensure that QFontDialog::getFont() works on Mac OS X.
diff --git a/src/gui/styles/qmotifstyle.cpp b/src/gui/styles/qmotifstyle.cpp
index 7d4fab8..d19750f 100644
--- a/src/gui/styles/qmotifstyle.cpp
+++ b/src/gui/styles/qmotifstyle.cpp
@@ -298,8 +298,11 @@ void QMotifStyle::unpolish(QWidget* widget)
{
QCommonStyle::unpolish(widget);
#ifndef QT_NO_PROGRESSBAR
- if (qobject_cast<QProgressBar *>(widget))
+ if (qobject_cast<QProgressBar *>(widget)) {
+ Q_D(QMotifStyle);
widget->removeEventFilter(this);
+ d->bars.removeAll(static_cast<QProgressBar*>(widget));
+ }
#endif
}
diff --git a/tests/auto/qprogressbar/tst_qprogressbar.cpp b/tests/auto/qprogressbar/tst_qprogressbar.cpp
index d6379d3..cb037e0 100644
--- a/tests/auto/qprogressbar/tst_qprogressbar.cpp
+++ b/tests/auto/qprogressbar/tst_qprogressbar.cpp
@@ -63,6 +63,7 @@ private slots:
void setValueRepaint();
void sizeHint();
+ void task245201_testChangeStyleAndDelete_data();
void task245201_testChangeStyleAndDelete();
};
@@ -224,15 +225,30 @@ void tst_QProgressBar::sizeHint()
QCOMPARE(barSize.height(), size.height());
}
+void tst_QProgressBar::task245201_testChangeStyleAndDelete_data()
+{
+ QTest::addColumn<QString>("style1_str");
+ QTest::addColumn<QString>("style2_str");
+
+ QTest::newRow("plastique-windows") << QString::fromLatin1("plastique") << QString::fromLatin1("windows");
+ QTest::newRow("mlotif-windows") << QString::fromLatin1("motif") << QString::fromLatin1("windows");
+ QTest::newRow("cleanlooks-cde") << QString::fromLatin1("cleanlooks") << QString::fromLatin1("cde");
+ QTest::newRow("gtk-plastique") << QString::fromLatin1("gtk") << QString::fromLatin1("plastique");
+}
+
void tst_QProgressBar::task245201_testChangeStyleAndDelete()
{
+ QFETCH(QString, style1_str);
+ QFETCH(QString, style2_str);
+
QProgressBar *bar = new QProgressBar;
- QStyle *style = QStyleFactory::create("plastique");
+ QStyle *style = QStyleFactory::create(style1_str);
bar->setStyle(style);
bar->show();
- QStyle *style2 = QStyleFactory::create("windows");
+ QStyle *style2 = QStyleFactory::create(style2_str);
bar->setStyle(style2);
+ QTest::qWait(10);
delete bar;
QTest::qWait(100); //should not crash