Skip to content
Snippets Groups Projects
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
Branches
Tags
No related merge requests found
...@@ -240,6 +240,10 @@ void ...@@ -240,6 +240,10 @@ void
MessageListModel::moveMessage(const QString& msgId, const QString& parentId) MessageListModel::moveMessage(const QString& msgId, const QString& parentId)
{ {
int currentIndex = indexOfMessage(msgId); 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 // if we have a next element check if it is a child interaction
QString childMessageIdToMove; QString childMessageIdToMove;
...@@ -256,7 +260,7 @@ MessageListModel::moveMessage(const QString& msgId, const QString& parentId) ...@@ -256,7 +260,7 @@ MessageListModel::moveMessage(const QString& msgId, const QString& parentId)
newIndex = interactions_.size() - 1; newIndex = interactions_.size() - 1;
} }
if (currentIndex == newIndex) if (currentIndex == newIndex || newIndex == -1)
return; return;
moveMessage(currentIndex, newIndex); moveMessage(currentIndex, newIndex);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment