projects
/
quassel.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e28ac2c
)
Fixing selections, also prevent from crashing in some circumstances
author
Manuel Nickschas
<sputnick@quassel-irc.org>
Mon, 4 Aug 2008 11:32:58 +0000
(13:32 +0200)
committer
Manuel Nickschas
<sputnick@quassel-irc.org>
Mon, 4 Aug 2008 11:32:58 +0000
(13:32 +0200)
src/qtui/chatscene.cpp
patch
|
blob
|
history
diff --git
a/src/qtui/chatscene.cpp
b/src/qtui/chatscene.cpp
index
6dbe171
..
8f36e1d
100644
(file)
--- 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!
//!\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;
QString result;
- for(int l =
_selectionStart; l <= _selectionE
nd; l++) {
+ for(int l =
start; l <= e
nd; l++) {
if(_selectionMinCol == ChatLineModel::TimestampColumn)
result += _lines[l]->item(ChatLineModel::TimestampColumn)->data(MessageModel::DisplayRole).toString() + " ";
if(_selectionMinCol <= ChatLineModel::SenderColumn)
if(_selectionMinCol == ChatLineModel::TimestampColumn)
result += _lines[l]->item(ChatLineModel::TimestampColumn)->data(MessageModel::DisplayRole).toString() + " ";
if(_selectionMinCol <= ChatLineModel::SenderColumn)