forked from qt-creator/qt-creator
Fix crash with "Files in Any/Current Project" locator filters
They were calling thread-unsafe API from a non-GUI thread. Task-number: QTCREATORBUG-12592 Change-Id: I029eebae341643060ca1d1a685e2a5730f9cf964 Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
This commit is contained in:
@@ -46,6 +46,7 @@ public:
|
||||
void accept(Core::LocatorFilterEntry selection) const;
|
||||
|
||||
protected:
|
||||
// runs in non-UI thread
|
||||
virtual void updateFiles();
|
||||
void generateFileNames();
|
||||
|
||||
|
@@ -55,16 +55,21 @@ void AllProjectsFilter::markFilesAsOutOfDate()
|
||||
m_filesUpToDate = false;
|
||||
}
|
||||
|
||||
void AllProjectsFilter::updateFiles()
|
||||
void AllProjectsFilter::updateFilesImpl()
|
||||
{
|
||||
if (m_filesUpToDate)
|
||||
return;
|
||||
m_filesUpToDate = true;
|
||||
files().clear();
|
||||
foreach (Project *project, SessionManager::projects())
|
||||
files().append(project->files(Project::AllFiles));
|
||||
Utils::sort(files());
|
||||
generateFileNames();
|
||||
m_filesUpToDate = true;
|
||||
}
|
||||
|
||||
void AllProjectsFilter::updateFiles()
|
||||
{
|
||||
QMetaObject::invokeMethod(this, "updateFilesImpl", Qt::BlockingQueuedConnection);
|
||||
}
|
||||
|
||||
void AllProjectsFilter::refresh(QFutureInterface<void> &future)
|
||||
|
@@ -50,6 +50,7 @@ protected:
|
||||
|
||||
private slots:
|
||||
void markFilesAsOutOfDate();
|
||||
void updateFilesImpl();
|
||||
|
||||
private:
|
||||
bool m_filesUpToDate;
|
||||
|
@@ -57,17 +57,22 @@ void CurrentProjectFilter::markFilesAsOutOfDate()
|
||||
m_filesUpToDate = false;
|
||||
}
|
||||
|
||||
void CurrentProjectFilter::updateFiles()
|
||||
void CurrentProjectFilter::updateFilesImpl()
|
||||
{
|
||||
if (m_filesUpToDate)
|
||||
return;
|
||||
m_filesUpToDate = true;
|
||||
files().clear();
|
||||
if (!m_project)
|
||||
return;
|
||||
files() = m_project->files(Project::AllFiles);
|
||||
Utils::sort(files());
|
||||
generateFileNames();
|
||||
m_filesUpToDate = true;
|
||||
}
|
||||
|
||||
void CurrentProjectFilter::updateFiles()
|
||||
{
|
||||
QMetaObject::invokeMethod(this, "updateFilesImpl", Qt::BlockingQueuedConnection);
|
||||
}
|
||||
|
||||
void CurrentProjectFilter::currentProjectChanged(ProjectExplorer::Project *project)
|
||||
|
@@ -54,6 +54,7 @@ protected:
|
||||
private slots:
|
||||
void currentProjectChanged(ProjectExplorer::Project *project);
|
||||
void markFilesAsOutOfDate();
|
||||
void updateFilesImpl();
|
||||
|
||||
private:
|
||||
Project *m_project;
|
||||
|
Reference in New Issue
Block a user