Prevent quasselclient from crashing when there's no account yet
authorBruno Bigras <bigras.bruno@gmail.com>
Tue, 19 Jan 2010 16:45:50 +0000 (11:45 -0500)
committerManuel Nickschas <sputnick@quassel-irc.org>
Mon, 25 Jan 2010 21:35:06 +0000 (22:35 +0100)
src/client/coreaccountmodel.cpp

index 1ab159c..a7a2f01 100644 (file)
@@ -39,11 +39,13 @@ CoreAccountModel::CoreAccountModel(const CoreAccountModel *other, QObject *paren
 
 void CoreAccountModel::update(const CoreAccountModel *other) {
   clear();
 
 void CoreAccountModel::update(const CoreAccountModel *other) {
   clear();
-  beginInsertRows(QModelIndex(), 0, other->_accounts.count() -1);
+  if (other->_accounts.count() > 0) {
+    beginInsertRows(QModelIndex(), 0, other->_accounts.count() -1);
+    _accounts = other->_accounts;
+    endInsertRows();
+  }
   _internalAccount = other->internalAccount();
   _internalAccount = other->internalAccount();
-  _accounts = other->_accounts;
   _removedAccounts = other->_removedAccounts;
   _removedAccounts = other->_removedAccounts;
-  endInsertRows();
 }
 
 void CoreAccountModel::load() {
 }
 
 void CoreAccountModel::load() {