From 52e7aba6bf717c673151c9267040c7a90dbea039 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 24 Jun 2015 10:31:07 +0200 Subject: QFileIconEngine: Remove reference to QFileIconProvider MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Keeping the reference may end up in a crash if a created QIcon outlives the QFileIconProvider and we then try to generate a pixmap. The reference is not necessary since the options are queried only when creating the icon, so they can be saved in the icon provider. Task-number: QTBUG-46755 Change-Id: I5c60887c2ed39030a2a20298ff10fd652189e4e7 Reviewed-by: Timur Pocheptsov Reviewed-by: Marc Mutz Reviewed-by: Morten Johan Sørvig --- .../qfileiconprovider/tst_qfileiconprovider.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests/auto/widgets') diff --git a/tests/auto/widgets/itemviews/qfileiconprovider/tst_qfileiconprovider.cpp b/tests/auto/widgets/itemviews/qfileiconprovider/tst_qfileiconprovider.cpp index 0bc972d0cb..fba83a24c7 100644 --- a/tests/auto/widgets/itemviews/qfileiconprovider/tst_qfileiconprovider.cpp +++ b/tests/auto/widgets/itemviews/qfileiconprovider/tst_qfileiconprovider.cpp @@ -58,6 +58,8 @@ private slots: void type_data(); void type(); + + void taskQTBUG_46755_QFileIconEngine_crash(); }; // Subclass that exposes the protected functions. @@ -167,6 +169,21 @@ void tst_QFileIconProvider::type() QVERIFY(!provider.type(info).isEmpty()); } +static QIcon getIcon() +{ + QFileIconProvider fip; + return fip.icon(QDir::currentPath()); +} + +void tst_QFileIconProvider::taskQTBUG_46755_QFileIconEngine_crash() +{ + const QIcon &icon = getIcon(); + foreach (const QSize &size, icon.availableSizes()) + icon.pixmap(size); + + // No crash, all good. +} + QTEST_MAIN(tst_QFileIconProvider) #include "tst_qfileiconprovider.moc" -- cgit v1.2.3