summaryrefslogtreecommitdiff
path: root/src/plugins/projectexplorer/taskhub.cpp
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@digia.com>2014-04-10 12:44:13 +0200
committerTobias Hunger <tobias.hunger@digia.com>2014-04-10 13:30:24 +0200
commitcf618464d2c9f2a9f9a3db0b41b556e3cd4ef6ae (patch)
treecffa3c050a3f3654885f654ff81bf47ae2a17b1e /src/plugins/projectexplorer/taskhub.cpp
parent2e22993c8349b5c23ff6a73c11200f6414b3b1b6 (diff)
downloadqt-creator-cf618464d2c9f2a9f9a3db0b41b556e3cd4ef6ae.tar.gz
TaskHub: Sanitize tasks and reject obviously invalid ones.
I hope this helps to track down tasks as described in QTCREATORBUG-11976 Change-Id: I758c28c56ad69aa0c19896065925de188475bda3 Reviewed-by: Daniel Teske <daniel.teske@digia.com>
Diffstat (limited to 'src/plugins/projectexplorer/taskhub.cpp')
-rw-r--r--src/plugins/projectexplorer/taskhub.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/plugins/projectexplorer/taskhub.cpp b/src/plugins/projectexplorer/taskhub.cpp
index 990734c09c..eb3a9e15eb 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<Core::Id> 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);
}