diff --git a/src/plugins/projectexplorer/task.cpp b/src/plugins/projectexplorer/task.cpp index 91e6d5c987b..5849601ca0a 100644 --- a/src/plugins/projectexplorer/task.cpp +++ b/src/plugins/projectexplorer/task.cpp @@ -83,10 +83,10 @@ Task Task::buildConfigurationMissingTask() Constants::TASK_CATEGORY_BUILDSYSTEM); } -void Task::addMark(TextEditor::TextMark *mark) +void Task::setMark(TextEditor::TextMark *mark) { + QTC_ASSERT(mark, return); QTC_ASSERT(m_mark.isNull(), return); - m_mark = QSharedPointer(mark); } diff --git a/src/plugins/projectexplorer/task.h b/src/plugins/projectexplorer/task.h index 592bef9cab7..af8126c40eb 100644 --- a/src/plugins/projectexplorer/task.h +++ b/src/plugins/projectexplorer/task.h @@ -37,6 +37,8 @@ namespace ProjectExplorer { +class TaskHub; + // Documentation inside. class PROJECTEXPLORER_EXPORT Task { @@ -66,7 +68,6 @@ public: int movedLine = -1; // contains a line number if the line was moved in the editor Core::Id category; QIcon icon; - void addMark(TextEditor::TextMark *mark); // Having a QList in Task isn't that great // It would be cleaner to split up the text into @@ -79,8 +80,12 @@ public: QList formats; private: + void setMark(TextEditor::TextMark *mark); + QSharedPointer m_mark; static unsigned int s_nextId; + + friend class TaskHub; }; bool PROJECTEXPLORER_EXPORT operator==(const Task &t1, const Task &t2); diff --git a/src/plugins/projectexplorer/taskhub.cpp b/src/plugins/projectexplorer/taskhub.cpp index 2ce383bc6b2..16b2f7dd9a3 100644 --- a/src/plugins/projectexplorer/taskhub.cpp +++ b/src/plugins/projectexplorer/taskhub.cpp @@ -134,6 +134,8 @@ void TaskHub::addTask(Task task) { QTC_ASSERT(m_registeredCategories.contains(task.category), return); QTC_ASSERT(!task.description.isEmpty(), return); + QTC_ASSERT(!task.isNull(), return); + QTC_ASSERT(task.m_mark.isNull(), return); if (task.file.isEmpty()) task.line = -1; @@ -146,7 +148,7 @@ void TaskHub::addTask(Task task) auto mark = new TaskMark(task.taskId, task.file.toString(), task.line, task.type, !task.icon.isNull()); mark->setIcon(task.icon); mark->setPriority(TextEditor::TextMark::LowPriority); - task.addMark(mark); + task.setMark(mark); } emit m_instance->taskAdded(task); }