Commit f719706b authored by Sébastien Blin's avatar Sébastien Blin
Browse files

messagelistmodel: protect against crash on incorrect index

Change-Id: Icaaf1f1628a1bd0b8f3fe1992424abb4d2b60bf3
parent 88ca4fb3
......@@ -240,6 +240,10 @@ void
MessageListModel::moveMessage(const QString& msgId, const QString& parentId)
{
int currentIndex = indexOfMessage(msgId);
if (currentIndex == -1) {
qWarning() << "Incorrect index detected in MessageListModel::moveMessage";
return;
}
// if we have a next element check if it is a child interaction
QString childMessageIdToMove;
......@@ -256,7 +260,7 @@ MessageListModel::moveMessage(const QString& msgId, const QString& parentId)
newIndex = interactions_.size() - 1;
}
if (currentIndex == newIndex)
if (currentIndex == newIndex || newIndex == -1)
return;
moveMessage(currentIndex, newIndex);
......
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