Projects: Create QIcons in the UI thread

Creating QIcons elsewhere is not safe because of image reader plugin
loading and the pixmap cache.

Fixes: QTCREATORBUG-25301
Change-Id: Ia22a0cd571f808d7f5c639353fdf2e548743f8ca
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
Eike Ziller
2021-04-08 16:31:31 +02:00
parent f4ab1279fd
commit bce81fd992
9 changed files with 116 additions and 41 deletions

View File

@@ -182,14 +182,12 @@ void addHeaderNodes(ProjectNode *root,
if (root->isEmpty())
return;
static QIcon headerNodeIcon = Core::FileIconProvider::directoryIcon(
ProjectExplorer::Constants::FILEOVERLAY_H);
auto headerNode = std::make_unique<VirtualFolderNode>(root->filePath());
headerNode->setPriority(Node::DefaultPriority - 5);
headerNode->setDisplayName(
QCoreApplication::translate("CMakeProjectManager::Internal::ProjectTreeHelper",
"<Headers>"));
headerNode->setIcon(headerNodeIcon);
headerNode->setIcon(DirectoryIcon(ProjectExplorer::Constants::FILEOVERLAY_H));
// Add scanned headers:
for (const FileNode *fn : allFiles) {
@@ -212,15 +210,13 @@ void addFileSystemNodes(ProjectNode *root, const QList<const FileNode *> &allFil
{
QTC_ASSERT(root, return );
static QIcon fileSystemNodeIcon = Core::FileIconProvider::directoryIcon(
ProjectExplorer::Constants::FILEOVERLAY_UNKNOWN);
auto fileSystemNode = std::make_unique<VirtualFolderNode>(root->filePath());
// just before special nodes like "CMake Modules"
fileSystemNode->setPriority(Node::DefaultPriority - 6);
fileSystemNode->setDisplayName(
QCoreApplication::translate("CMakeProjectManager::Internal::ProjectTreeHelper",
"<File System>"));
fileSystemNode->setIcon(fileSystemNodeIcon);
fileSystemNode->setIcon(DirectoryIcon(ProjectExplorer::Constants::FILEOVERLAY_UNKNOWN));
for (const FileNode *fn : allFiles) {
if (!fn->filePath().isChildOf(root->filePath()))