diff --git a/src/plugins/projectexplorer/task.cpp b/src/plugins/projectexplorer/task.cpp index 462e7e6d07c..74995d2b321 100644 --- a/src/plugins/projectexplorer/task.cpp +++ b/src/plugins/projectexplorer/task.cpp @@ -29,6 +29,8 @@ #include "task.h" +#include + namespace ProjectExplorer { @@ -68,6 +70,8 @@ Task::Task(TaskType type_, const QString &description_, void Task::addMark(TextEditor::BaseTextMark *mark) { + QTC_ASSERT(m_mark.isNull(), return); + m_mark = QSharedPointer(mark); } diff --git a/src/plugins/projectexplorer/taskhub.cpp b/src/plugins/projectexplorer/taskhub.cpp index 990734c09c1..eb3a9e15eb2 100644 --- a/src/plugins/projectexplorer/taskhub.cpp +++ b/src/plugins/projectexplorer/taskhub.cpp @@ -35,6 +35,7 @@ using namespace ProjectExplorer; TaskHub *m_instance = 0; +QSet TaskHub::m_registededCategories; class TaskMark : public TextEditor::BaseTextMark { @@ -99,6 +100,7 @@ TaskHub::~TaskHub() void TaskHub::addCategory(Core::Id categoryId, const QString &displayName, bool visible) { QTC_CHECK(!displayName.isEmpty()); + QTC_ASSERT(!m_registededCategories.contains(categoryId), return); emit m_instance->categoryAdded(categoryId, displayName, visible); } @@ -114,6 +116,16 @@ void TaskHub::addTask(Task::TaskType type, const QString &description, Core::Id void TaskHub::addTask(Task task) { + QTC_ASSERT(m_registededCategories.contains(task.category), return); + QTC_ASSERT(!task.description.isEmpty(), return); + + if (task.file.isEmpty()) + task.line = -1; + + if (task.line <= 0) + task.line = -1; + task.movedLine = task.line; + if (task.line != -1 && !task.file.isEmpty()) { TaskMark *mark = new TaskMark(task.taskId, task.file.toString(), task.line, !task.icon.isNull()); mark->setIcon(task.icon); @@ -128,6 +140,7 @@ void TaskHub::addTask(Task task) void TaskHub::clearTasks(Core::Id categoryId) { + QTC_ASSERT(m_registededCategories.contains(categoryId), return); emit m_instance->tasksCleared(categoryId); } @@ -158,6 +171,7 @@ void TaskHub::showTaskInEditor(unsigned int id) void TaskHub::setCategoryVisibility(const Core::Id &categoryId, bool visible) { + QTC_ASSERT(m_registededCategories.contains(categoryId), return); emit m_instance->categoryVisibilityChanged(categoryId, visible); } diff --git a/src/plugins/projectexplorer/taskhub.h b/src/plugins/projectexplorer/taskhub.h index 77cc75bf68e..5edd12fc7ed 100644 --- a/src/plugins/projectexplorer/taskhub.h +++ b/src/plugins/projectexplorer/taskhub.h @@ -85,6 +85,8 @@ private: const QIcon m_errorIcon; const QIcon m_warningIcon; + static QSet m_registededCategories; + friend class ProjectExplorerPlugin; };