From 02cbfa917a3460fff89904eb15402ede3a1b7bb2 Mon Sep 17 00:00:00 2001 From: Mike Gelfand Date: Thu, 13 Oct 2022 16:19:37 -0700 Subject: [PATCH] Don't scroll to message log bottom with no messages (GTK client) (#3959) Fixes: #3956 --- gtk/MessageLogWindow.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/gtk/MessageLogWindow.cc b/gtk/MessageLogWindow.cc index f00fb57ac..228963c54 100644 --- a/gtk/MessageLogWindow.cc +++ b/gtk/MessageLogWindow.cc @@ -123,14 +123,15 @@ bool MessageLogWindow::Impl::is_pinned_to_new() const void MessageLogWindow::Impl::scroll_to_bottom() { - if (sort_ != nullptr) + auto const row_count = sort_->children().size(); + if (row_count == 0) { - auto const row_count = sort_->children().size(); + return; + } - if (auto const iter = sort_->children()[row_count - 1]; iter) - { - view_->scroll_to_row(sort_->get_path(TR_GTK_TREE_MODEL_CHILD_ITER(iter)), 1); - } + if (auto const iter = sort_->children()[row_count - 1]; iter) + { + view_->scroll_to_row(sort_->get_path(TR_GTK_TREE_MODEL_CHILD_ITER(iter)), 1); } }