From 3bc96dad902f295cb49bd08ea125452ecc78848f Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Mon, 11 Apr 2016 13:27:42 +0200 Subject: [PATCH] ProjectExplorer: Rename Task::addMark to setMark and make it private Make TaskHub a friend of Task so that it can still use the method. This should stop anyone from accidentally calling that. Change-Id: I36974d0ba874f0cac59b7c57ed667ce2e75e1d4c Reviewed-by: Eike Ziller --- src/plugins/projectexplorer/task.cpp | 4 ++-- src/plugins/projectexplorer/task.h | 7 ++++++- src/plugins/projectexplorer/taskhub.cpp | 4 +++- 3 files changed, 11 insertions(+), 4 deletions(-) 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); }