From: Marcus Eggenberger Date: Mon, 27 Oct 2008 12:58:16 +0000 (+0100) Subject: fixing a crash if there are no visible messages in a chatscene X-Git-Tag: 0.3.1~121 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=954b1a6f53da55f9713fb4e75a2fb46dae7d9df8 fixing a crash if there are no visible messages in a chatscene --- diff --git a/src/qtui/chatscene.cpp b/src/qtui/chatscene.cpp index f71c8572..c24933a2 100644 --- a/src/qtui/chatscene.cpp +++ b/src/qtui/chatscene.cpp @@ -573,9 +573,14 @@ void ChatScene::updateSceneRect(qreal width) { } // the following call should be safe. If it crashes something went wrong during insert/remove - ChatLine *firstLine = _lines.at(_firstLineRow); - ChatLine *lastLine = _lines.last(); - updateSceneRect(QRectF(0, firstLine->pos().y(), width, lastLine->pos().y() + lastLine->height() - firstLine->pos().y())); + if(_firstLineRow < _lines.count()) { + ChatLine *firstLine = _lines.at(_firstLineRow); + ChatLine *lastLine = _lines.last(); + updateSceneRect(QRectF(0, firstLine->pos().y(), width, lastLine->pos().y() + lastLine->height() - firstLine->pos().y())); + } else { + // empty scene rect + updateSceneRect(QRectF(0, 0, width, 0)); + } } void ChatScene::updateSceneRect(const QRectF &rect) {