From 954b1a6f53da55f9713fb4e75a2fb46dae7d9df8 Mon Sep 17 00:00:00 2001 From: Marcus Eggenberger Date: Mon, 27 Oct 2008 13:58:16 +0100 Subject: [PATCH] fixing a crash if there are no visible messages in a chatscene --- src/qtui/chatscene.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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) { -- 2.20.1