mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 21:40:19 +00:00
Fix crash when the Outline dialog is opened on an empty document. This was caused by the commented out updateLabels() in LyXFunc::menuNew().
* Text: new empty() method. * buffer_funcs.cpp:updateLabels(): return early in case of empty document. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19566 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
8a221dc70c
commit
8f83eab31f
@ -1998,7 +1998,7 @@ void LyXFunc::menuNew(string const & name, bool fromTemplate)
|
||||
|
||||
Buffer * const b = newFile(filename, templname, !name.empty());
|
||||
if (b) {
|
||||
//updateLabels(*b);
|
||||
updateLabels(*b);
|
||||
lyx_view_->setBuffer(b);
|
||||
}
|
||||
}
|
||||
|
@ -344,6 +344,13 @@ void readParagraph(Buffer const & buf, Paragraph & par, Lexer & lex,
|
||||
} // namespace anon
|
||||
|
||||
|
||||
bool Text::empty() const
|
||||
{
|
||||
return pars_.empty() || (pars_.size() == 1 && pars_[0].empty()
|
||||
// FIXME: Should we consider the labeled type as empty too?
|
||||
&& pars_[0].layout()->labeltype == LABEL_NO_LABEL);
|
||||
}
|
||||
|
||||
|
||||
double Text::spacing(Buffer const & buffer,
|
||||
Paragraph const & par) const
|
||||
|
@ -49,6 +49,11 @@ public:
|
||||
/// constructor
|
||||
explicit Text();
|
||||
|
||||
/// \return true if there's no content at all.
|
||||
/// \warning a non standard layout on an empty paragraph doesn't
|
||||
// count as empty.
|
||||
bool empty() const;
|
||||
|
||||
///
|
||||
Font getFont(Buffer const & buffer, Paragraph const & par,
|
||||
pos_type pos) const;
|
||||
|
@ -578,6 +578,8 @@ void updateLabels(Buffer const & buf, ParIterator & parit)
|
||||
}
|
||||
|
||||
|
||||
// FIXME: buf should should be const because updateLabels() modifies
|
||||
// the contents of the paragraphs.
|
||||
void updateLabels(Buffer const & buf, bool childonly)
|
||||
{
|
||||
Buffer const * const master = buf.getMasterBuffer();
|
||||
@ -595,11 +597,20 @@ void updateLabels(Buffer const & buf, bool childonly)
|
||||
textclass.counters().reset();
|
||||
}
|
||||
|
||||
Buffer & cbuf = const_cast<Buffer &>(buf);
|
||||
|
||||
if (buf.text().empty()) {
|
||||
// FIXME: we don't call continue with updateLabels() here because
|
||||
// it crashes on newly created documents. But the TocBackend needs to
|
||||
// be initialised nonetheless so we update the tocBackend manually.
|
||||
cbuf.tocBackend().update();
|
||||
return;
|
||||
}
|
||||
|
||||
// do the real work
|
||||
ParIterator parit = par_iterator_begin(buf.inset());
|
||||
updateLabels(buf, parit);
|
||||
|
||||
Buffer & cbuf = const_cast<Buffer &>(buf);
|
||||
cbuf.tocBackend().update();
|
||||
if (!childonly)
|
||||
cbuf.structureChanged();
|
||||
|
Loading…
Reference in New Issue
Block a user