From 0823fb6f86993ed715948d65457234b2899803c3 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Mon, 16 Oct 2006 08:51:55 +0000 Subject: [PATCH] Fix Toc dialog crash when TOC is empty. * QToc::update(): return early if no TOC type. * QTocDialog::updateGui(): return early of the Type model is empty and disable the outline buttons. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15346 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/QToc.C | 6 ++++++ src/frontends/qt4/QTocDialog.C | 13 +++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/frontends/qt4/QToc.C b/src/frontends/qt4/QToc.C index 57965fb538..a85e961741 100644 --- a/src/frontends/qt4/QToc.C +++ b/src/frontends/qt4/QToc.C @@ -43,6 +43,9 @@ bool QToc::canOutline() { vector const & types = getTypes(); + if (types.empty()) + return false; + BOOST_ASSERT(type_ >= 0 && type_ < int(types.size())); return ControlToc::canOutline(types[type_]); } @@ -115,6 +118,9 @@ void QToc::update() type_ = 0; vector const & types = getTypes(); + if (types.empty()) + return; + string const & selected_type = toc::getType(params().getCmdName()); lyxerr[Debug::GUI] << "selected_type " << selected_type << endl; diff --git a/src/frontends/qt4/QTocDialog.C b/src/frontends/qt4/QTocDialog.C index 691aa56641..34556d9673 100644 --- a/src/frontends/qt4/QTocDialog.C +++ b/src/frontends/qt4/QTocDialog.C @@ -186,8 +186,17 @@ void QTocDialog::update() void QTocDialog::updateGui() { - typeCO->setModel(form_->typeModel()); - tocTV->setModel(form_->tocModel()); + QStringListModel * type_model = form_->typeModel(); + if (type_model->stringList().isEmpty()) + { + enableButtons(); + return; + } + + typeCO->setModel(type_model); + + if (form_->tocModel()) + tocTV->setModel(form_->tocModel()); tocTV->showColumn(0); // hide the pointless QHeader for now // in the future, new columns may appear -- 2.39.2