X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fchatscene.cpp;h=8f36e1d27446547e0bd11be24db9ba95bdbafa5d;hb=3307118b56d79f5ddf4f43cb955b66ea26332e5b;hp=6dbe17109f9966be9b11ab4debe174c131b96d1b;hpb=bd37d2c94e49e791d2ba44baab4270e030442832;p=quassel.git diff --git a/src/qtui/chatscene.cpp b/src/qtui/chatscene.cpp index 6dbe1710..8f36e1d2 100644 --- a/src/qtui/chatscene.cpp +++ b/src/qtui/chatscene.cpp @@ -252,9 +252,15 @@ void ChatScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { //!\brief Convert current selection to human-readable string. QString ChatScene::selectionToString() const { //TODO Make selection format configurable! - if(!_isSelecting) return ""; + if(!_isSelecting) return QString(); + int start = qMin(_selectionStart, _selectionEnd); + int end = qMax(_selectionStart, _selectionEnd); + if(start < 0 || end >= _lines.count()) { + qDebug() << "Invalid selection range:" << start << end; + return QString(); + } QString result; - for(int l = _selectionStart; l <= _selectionEnd; l++) { + for(int l = start; l <= end; l++) { if(_selectionMinCol == ChatLineModel::TimestampColumn) result += _lines[l]->item(ChatLineModel::TimestampColumn)->data(MessageModel::DisplayRole).toString() + " "; if(_selectionMinCol <= ChatLineModel::SenderColumn)