Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit a3a66bb1 authored by David Faure's avatar David Faure

Fix crash when comparing nodes with depth of -1

Summary:
Enabling a calendar with todos crashed for me.
Apparently because of missing parent todos.

Reviewers: smartins

Reviewed By: smartins

Subscribers: #kde_pim

Tags: #kde_pim

Differential Revision: https://phabricator.kde.org/D11517
parent 9abf9eeb
......@@ -38,13 +38,17 @@ static void calculateDepth(const Node::Ptr &node)
}
}
bool lessThan(const Node::Ptr &node1, const Node::Ptr &node2)
// Desired ordering [...],3,2,1,0,-1
static bool reverseDepthLessThan(const Node::Ptr &node1, const Node::Ptr &node2)
{
return node1->depth > node2->depth;
}
bool greaterThan(const PreNode::Ptr &node1, const PreNode::Ptr &node2)
// Desired ordering 0,1,2,3,[...],-1
static bool depthLessThan(const PreNode::Ptr &node1, const PreNode::Ptr &node2)
{
if (node1->depth == -1)
return false;
return node1->depth < node2->depth || node2->depth == -1;
}
......@@ -81,7 +85,7 @@ static PreNode::List sortedPrenodes(const PreNode::List &nodes)
}
PreNode::List sorted = nodes;
std::sort(sorted.begin(), sorted.end(), greaterThan);
std::sort(sorted.begin(), sorted.end(), depthLessThan);
return sorted;
}
......@@ -446,7 +450,7 @@ Node::List IncidenceTreeModel::Private::sorted(const Node::List &nodes) const
}
Node::List sorted = nodes;
std::sort(sorted.begin(), sorted.end(), lessThan);
std::sort(sorted.begin(), sorted.end(), reverseDepthLessThan);
return sorted;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment