X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fbuffer_funcs.cpp;h=17aab767c2c91c04b3a86a78533a7c5d97cd87da;hb=cca78e3c8ae27431323746abd64f9d7db017099d;hp=0bf934c63c6f9fde0abb25c5ebd0af5c167b3482;hpb=4bc7feaa96bb6a810464c41f1da9bb3d7f906580;p=lyx.git diff --git a/src/buffer_funcs.cpp b/src/buffer_funcs.cpp index 0bf934c63c..17aab767c2 100644 --- a/src/buffer_funcs.cpp +++ b/src/buffer_funcs.cpp @@ -60,7 +60,7 @@ namespace Alert = frontend::Alert; Buffer * checkAndLoadLyXFile(FileName const & filename) { // File already open? - Buffer * checkBuffer = theBufferList().getBuffer(filename.absFilename()); + Buffer * checkBuffer = theBufferList().getBuffer(filename); if (checkBuffer) { if (checkBuffer->isClean()) return checkBuffer; @@ -153,16 +153,15 @@ Buffer * newUnnamedFile(string const & templatename, FileName const & path) { static int newfile_number; - string document_path = path.absFilename(); - string filename = addName(document_path, + FileName filename(path, "newfile" + convert(++newfile_number) + ".lyx"); while (theBufferList().exists(filename) - || FileName(filename).isReadableFile()) { + || filename.isReadableFile()) { ++newfile_number; - filename = addName(document_path, + filename.set(path, "newfile" + convert(newfile_number) + ".lyx"); } - return newFile(filename, templatename, false); + return newFile(filename.absFilename(), templatename, false); } @@ -467,7 +466,6 @@ void updateLabels(Buffer const & buf, ParIterator & parit) InsetList::const_iterator end = parit->insetList().end(); for (; iit != end; ++iit) { parit.pos() = iit->pos; - iit->inset->setBuffer(const_cast(buf)); iit->inset->updateLabels(parit); } } @@ -492,19 +490,13 @@ void updateLabels(Buffer const & buf, bool childonly) // start over the counters textclass.counters().reset(); buf.clearReferenceCache(); + buf.inset().setBuffer(const_cast(buf)); buf.updateMacros(); } Buffer & cbuf = const_cast(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; - } + BOOST_ASSERT(!buf.text().paragraphs().empty()); // do the real work ParIterator parit = par_iterator_begin(buf.inset());