forked from qt-creator/qt-creator
FileSystemFilter: store the value of includeHidden in prepareSearch()
Since we don't guarantee the synchronization between a call to openConfigDialog() and matchesFor(), it may happen that these two methods are called simultaneously by two different threads. In theory, the value of m_includeHidden may be changed in gui thread by a call to openConfigDialog(), while at the same time it may be read in other thread, inside matchesFor(). As a safe solution we make a copy of this value inside prepareSearch() and use the copy later in matchesFor(). Change-Id: I83fb184ff1914e4c02ee799464ff0d89350ab49c Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -74,6 +74,7 @@ void FileSystemFilter::prepareSearch(const QString &entry)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(entry)
|
Q_UNUSED(entry)
|
||||||
m_currentDocumentDirectory = DocumentManager::fileDialogInitialDirectory();
|
m_currentDocumentDirectory = DocumentManager::fileDialogInitialDirectory();
|
||||||
|
m_currentIncludeHidden = m_includeHidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<LocatorFilterEntry> FileSystemFilter::matchesFor(QFutureInterface<LocatorFilterEntry> &future,
|
QList<LocatorFilterEntry> FileSystemFilter::matchesFor(QFutureInterface<LocatorFilterEntry> &future,
|
||||||
@@ -92,7 +93,7 @@ QList<LocatorFilterEntry> FileSystemFilter::matchesFor(QFutureInterface<LocatorF
|
|||||||
const QDir dirInfo(directory);
|
const QDir dirInfo(directory);
|
||||||
QDir::Filters dirFilter = QDir::Dirs|QDir::Drives|QDir::NoDot|QDir::NoDotDot;
|
QDir::Filters dirFilter = QDir::Dirs|QDir::Drives|QDir::NoDot|QDir::NoDotDot;
|
||||||
QDir::Filters fileFilter = QDir::Files;
|
QDir::Filters fileFilter = QDir::Files;
|
||||||
if (m_includeHidden) {
|
if (m_currentIncludeHidden) {
|
||||||
dirFilter |= QDir::Hidden;
|
dirFilter |= QDir::Hidden;
|
||||||
fileFilter |= QDir::Hidden;
|
fileFilter |= QDir::Hidden;
|
||||||
}
|
}
|
||||||
|
@@ -56,6 +56,7 @@ private:
|
|||||||
static MatchLevel matchLevelFor(const QRegularExpressionMatch &match, const QString &matchText);
|
static MatchLevel matchLevelFor(const QRegularExpressionMatch &match, const QString &matchText);
|
||||||
|
|
||||||
bool m_includeHidden = true;
|
bool m_includeHidden = true;
|
||||||
|
bool m_currentIncludeHidden = true;
|
||||||
QString m_currentDocumentDirectory;
|
QString m_currentDocumentDirectory;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user