aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2020-09-04 18:08:45 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2020-09-07 07:33:45 +0000
commit9c99aa223db8c9ae09c20387a82b23c03eee0e73 (patch)
tree6ab48e062583c9d69198a8efc35613f529cb7a5e /src
parent568cd8066e7b0e92ffaddc3109bd9677dbdde979 (diff)
ProjectExplorer: Delay task icon creation
Parsers can change the initial task type when accumulating output, and then the original icon would no longer match. To the user, the problem manifested itself by a missing error symbol in the issues pane and a missing text marker in the editor. Fix this by delaying creation of the icon until it is used. Change-Id: I5349f21c6c0d9bc39a5000ceb33faf88ea62eeac Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/projectexplorer/task.cpp11
-rw-r--r--src/plugins/projectexplorer/task.h3
-rw-r--r--src/plugins/projectexplorer/taskhub.cpp4
-rw-r--r--src/plugins/projectexplorer/taskmodel.cpp2
4 files changed, 14 insertions, 6 deletions
diff --git a/src/plugins/projectexplorer/task.cpp b/src/plugins/projectexplorer/task.cpp
index 045e461d43b..3ca1b969dae 100644
--- a/src/plugins/projectexplorer/task.cpp
+++ b/src/plugins/projectexplorer/task.cpp
@@ -67,7 +67,7 @@ Task::Task(TaskType type_, const QString &description,
const QIcon &icon, Options options) :
taskId(s_nextId), type(type_), options(options), summary(description),
line(line_), movedLine(line_), category(category_),
- icon(icon.isNull() ? taskTypeIcon(type_) : icon)
+ m_icon(icon)
{
++s_nextId;
setFile(file_);
@@ -108,7 +108,7 @@ void Task::clear()
line = -1;
movedLine = -1;
category = Utils::Id();
- icon = QIcon();
+ m_icon = QIcon();
formats.clear();
m_mark.clear();
}
@@ -133,6 +133,13 @@ QString Task::description() const
return desc;
}
+QIcon Task::icon() const
+{
+ if (m_icon.isNull())
+ m_icon = taskTypeIcon(type);
+ return m_icon;
+}
+
//
// functions
//
diff --git a/src/plugins/projectexplorer/task.h b/src/plugins/projectexplorer/task.h
index 9c991179777..61aa31e4fce 100644
--- a/src/plugins/projectexplorer/task.h
+++ b/src/plugins/projectexplorer/task.h
@@ -74,6 +74,7 @@ public:
void clear();
void setFile(const Utils::FilePath &file);
QString description() const;
+ QIcon icon() const;
unsigned int taskId = 0;
TaskType type = Unknown;
@@ -85,7 +86,6 @@ public:
int line = -1;
int movedLine = -1; // contains a line number if the line was moved in the editor
Utils::Id category;
- QIcon icon;
// Having a container of QTextLayout::FormatRange in Task isn't that great
// It would be cleaner to split up the text into
@@ -101,6 +101,7 @@ private:
void setMark(TextEditor::TextMark *mark);
QSharedPointer<TextEditor::TextMark> m_mark;
+ mutable QIcon m_icon;
static unsigned int s_nextId;
friend class TaskHub;
diff --git a/src/plugins/projectexplorer/taskhub.cpp b/src/plugins/projectexplorer/taskhub.cpp
index d2528d955c6..856959ed0a2 100644
--- a/src/plugins/projectexplorer/taskhub.cpp
+++ b/src/plugins/projectexplorer/taskhub.cpp
@@ -78,8 +78,8 @@ public:
} else {
setToolTip(task.description());
}
- setIcon(task.icon);
- setVisible(!task.icon.isNull());
+ setIcon(task.icon());
+ setVisible(!task.icon().isNull());
}
bool isClickable() const override;
diff --git a/src/plugins/projectexplorer/taskmodel.cpp b/src/plugins/projectexplorer/taskmodel.cpp
index 7dc9f66b533..a52f2ff3ac6 100644
--- a/src/plugins/projectexplorer/taskmodel.cpp
+++ b/src/plugins/projectexplorer/taskmodel.cpp
@@ -255,7 +255,7 @@ QVariant TaskModel::data(const QModelIndex &index, int role) const
else if (role == TaskModel::Category)
return m_tasks.at(index.row()).category.uniqueIdentifier();
else if (role == TaskModel::Icon)
- return m_tasks.at(index.row()).icon;
+ return m_tasks.at(index.row()).icon();
else if (role == TaskModel::Task_t)
return QVariant::fromValue(task(index));
return QVariant();