From 251921c456502d60a0e04e65ab05f6141bc52f31 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Fri, 20 Jul 2001 09:33:28 +0000 Subject: [PATCH] Fix a crash when reading in an empty LyX document or one containing only a single collapsable inset. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2288 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView_pimpl.C | 10 +++++----- src/ChangeLog | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index f0c6fc86c0..16c82432c3 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -377,7 +377,6 @@ void BufferView::Pimpl::updateScrollbar() /* If the text is smaller than the working area, the scrollbar * maximum must be the working area height. No scrolling will * be possible */ - if (!bv_->text) { workarea_.setScrollbar(0, 1.0); return; @@ -386,11 +385,12 @@ void BufferView::Pimpl::updateScrollbar() long const text_height = bv_->text->height; double const lineh = bv_->text->defaultHeight(); - double const slider_size = 1.0 / double(text_height); + double const slider_size = + (text_height == 0) ? 1.0 : 1.0 / double(text_height); - static long old_text_height; - static double old_lineh; - static double old_slider_size; + static long old_text_height = 0; + static double old_lineh = 0; + static double old_slider_size = 0; if (text_height != old_text_height) { workarea_.setScrollbarBounds(0, text_height - workarea_.height()); diff --git a/src/ChangeLog b/src/ChangeLog index ea3292dbf1..c1185489c7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2001-07-20 Angus Leeming + + * BufferView_pimpl.C (updateScrollbar): Fix crash when reading in + a document of zero size. + 2001-07-19 Angus Leeming * LaTeXFeatures.[Ch]: add variable "bool natbib" and set it -- 2.39.5