mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 11:08:41 +00:00
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:
parent
77e145a406
commit
0823fb6f86
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user