]> git.lyx.org Git - features.git/commitdiff
Fix Toc dialog crash when TOC is empty.
authorAbdelrazak Younes <younes@lyx.org>
Mon, 16 Oct 2006 08:51:55 +0000 (08:51 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Mon, 16 Oct 2006 08:51:55 +0000 (08:51 +0000)
* 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
src/frontends/qt4/QTocDialog.C

index 57965fb538f2e6a79eba2ed3ad1855c5c93aa5e3..a85e961741b92b09a20edf5685f4a874c3e875ab 100644 (file)
@@ -43,6 +43,9 @@ bool QToc::canOutline()
 {
        vector<string> 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<string> const & types = getTypes();
+       if (types.empty())
+               return;
+
        string const & selected_type = toc::getType(params().getCmdName());
        lyxerr[Debug::GUI] << "selected_type " << selected_type << endl;
 
index 691aa566419c413477f6aea1638d6abad034ad1c..34556d96732df8be1a16820cd07321ab289d2e09 100644 (file)
@@ -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