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
This commit is contained in:
Abdelrazak Younes 2006-10-16 08:51:55 +00:00
parent 77e145a406
commit 0823fb6f86
2 changed files with 17 additions and 2 deletions

View 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;

View 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