Don't crash on creating a ChatView containing redirected messages
authorManuel Nickschas <sputnick@quassel-irc.org>
Tue, 15 Sep 2009 12:09:31 +0000 (14:09 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Tue, 15 Sep 2009 12:09:31 +0000 (14:09 +0200)
We must fill the model first before we connect the dataChanged() signal, because message filters
might setData() while populating proxymodels.

src/qtui/chatscene.cpp

index 19f48ff..411cdb8 100644 (file)
@@ -92,15 +92,15 @@ ChatScene::ChatScene(QAbstractItemModel *model, const QString &idString, qreal w
 
   setHandleXLimits();
 
+  if(model->rowCount() > 0)
+    rowsInserted(QModelIndex(), 0, model->rowCount() - 1);
+
   connect(model, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
           this, SLOT(rowsInserted(const QModelIndex &, int, int)));
   connect(model, SIGNAL(rowsAboutToBeRemoved(const QModelIndex &, int, int)),
           this, SLOT(rowsAboutToBeRemoved(const QModelIndex &, int, int)));
   connect(model, SIGNAL(dataChanged(QModelIndex, QModelIndex)), SLOT(dataChanged(QModelIndex, QModelIndex)));
 
-  if(model->rowCount() > 0)
-    rowsInserted(QModelIndex(), 0, model->rowCount() - 1);
-
 #ifdef HAVE_WEBKIT
   webPreview.timer.setSingleShot(true);
   connect(&webPreview.timer, SIGNAL(timeout()), this, SLOT(webPreviewNextStep()));