Fixing the remaining crash that might have happened while selecting
authorManuel Nickschas <sputnick@quassel-irc.org>
Wed, 20 Aug 2008 14:01:54 +0000 (16:01 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 20 Aug 2008 14:01:54 +0000 (16:01 +0200)
src/qtui/chatitem.cpp

index 602a2c9..127d3ba 100644 (file)
@@ -153,10 +153,8 @@ void ChatItem::setFullSelection() {
 }
 
 void ChatItem::clearSelection() {
-  if(_selectionMode != NoSelection) {
-    _selectionMode = NoSelection;
-    update();
-  }
+  _selectionMode = NoSelection;
+  update();
 }
 
 void ChatItem::continueSelecting(const QPointF &pos) {
@@ -195,15 +193,10 @@ QList<QRectF> ChatItem::findWords(const QString &searchWord, Qt::CaseSensitivity
 
 void ChatItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
   if(event->buttons() == Qt::LeftButton) {
-    if(_selectionMode == NoSelection) {
-      chatScene()->setSelectingItem(this);  // removes earlier selection if exists
-      _selectionStart = _selectionEnd = posToCursor(event->pos());
-      //_selectionMode = PartialSelection;
-    } else {
-      chatScene()->setSelectingItem(0);
-      _selectionMode = NoSelection;
-      update();
-    }
+    chatScene()->setSelectingItem(this);
+    _selectionStart = _selectionEnd = posToCursor(event->pos());
+    _selectionMode = NoSelection; // will be set to PartialSelection by mouseMoveEvent
+    update();
     event->accept();
   } else {
     event->ignore();
@@ -216,8 +209,7 @@ void ChatItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
       qint16 end = posToCursor(event->pos());
       if(end != _selectionEnd) {
         _selectionEnd = end;
-        if(_selectionStart != _selectionEnd) _selectionMode = PartialSelection;
-        else _selectionMode = NoSelection;
+        _selectionMode = (_selectionStart != _selectionEnd ? PartialSelection : NoSelection);
         update();
       }
     } else {