Fix QFileSelectorPrivate::addStatics()

It must clear the previously cached sharedData->staticSelectors,
or else QFileSelectorPrivate::updateSelectors() does nothing and
the newly added static selectors end up being ignored.

Change-Id: If6997664629199be9f00de64c5dd01de2bf0a044
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
This commit is contained in:
J-P Nurmi 2016-02-12 13:05:28 +01:00
parent 10742cf894
commit 5be4f95d95
2 changed files with 12 additions and 0 deletions

View File

@ -396,6 +396,7 @@ void QFileSelectorPrivate::addStatics(const QStringList &statics)
{
QMutexLocker locker(&sharedDataMutex);
sharedData->preloadedStatics << statics;
sharedData->staticSelectors.clear();
}
QT_END_NAMESPACE

View File

@ -55,6 +55,8 @@ private slots:
void urlConvenience_data();
void urlConvenience();
void addStatics();
};
void tst_QFileSelector::basicTest_data()
@ -224,5 +226,14 @@ void tst_QFileSelector::urlConvenience()
QCOMPARE(fs.select(testUrl), expectedUrl);
}
void tst_QFileSelector::addStatics()
{
QFileSelector fs;
QCOMPARE(fs.select(QStringLiteral(":/extras/test")), QStringLiteral(":/extras/test"));
QFileSelectorPrivate::addStatics(QStringList() << QStringLiteral("custom1"));
QCOMPARE(fs.select(QStringLiteral(":/extras/test")), QStringLiteral(":/extras/+custom1/test"));
}
QTEST_MAIN(tst_QFileSelector)
#include "tst_qfileselector.moc"