Prevent quasselclient from crashing when using the 'cancel' button of the 'Authorisat...
authorBruno Bigras <bigras.bruno@gmail.com>
Tue, 19 Jan 2010 16:58:23 +0000 (11:58 -0500)
committerManuel Nickschas <sputnick@quassel-irc.org>
Mon, 25 Jan 2010 21:35:06 +0000 (22:35 +0100)
src/client/messagemodel.cpp

index ba5db09..d10a9bc 100644 (file)
@@ -307,10 +307,12 @@ void MessageModel::customEvent(QEvent *event) {
 }
 
 void MessageModel::clear() {
-  beginRemoveRows(QModelIndex(), 0, rowCount() - 1);
-  removeAllMessages();
-  endRemoveRows();
   _messagesWaiting.clear();
+  if (rowCount() > 0) {
+    beginRemoveRows(QModelIndex(), 0, rowCount() - 1);
+    removeAllMessages();
+    endRemoveRows();
+  }
 }
 
 // returns index of msg with given Id or of the next message after that (i.e., the index where we'd insert this msg)