]> git.lyx.org Git - features.git/blobdiff - src/buffer_funcs.cpp
* Lazy MathData to avoid unneeded interpretation of macro definitions
[features.git] / src / buffer_funcs.cpp
index ee2b9a6b6559271b78b2ec68b634ce4bfefe0c41..d38e3aaaa7f0a6c344fdde46e8aa14688e94e6aa 100644 (file)
@@ -81,6 +81,9 @@ Buffer * checkAndLoadLyXFile(FileName const & filename)
 
        if (filename.isReadableFile()) {
                Buffer * b = theBufferList().newBuffer(filename.absFilename());
+               if (!b)
+                       // Buffer creation is not possible.
+                       return 0;
                if (!b->loadLyXFile(filename)) {
                        theBufferList().release(b);
                        return 0;
@@ -105,7 +108,9 @@ Buffer * newFile(string const & filename, string const & templatename,
 {
        // get a free buffer
        Buffer * b = theBufferList().newBuffer(filename);
-       BOOST_ASSERT(b);
+       if (!b)
+               // Buffer creation is not possible.
+               return 0;
 
        FileName tname;
        // use defaults.lyx as a default template if it exists.
@@ -405,6 +410,12 @@ void updateLabels(Buffer const & buf, ParIterator & parit)
 {
        BOOST_ASSERT(parit.pit() == 0);
 
+       // set the position of the text in the buffer to be able
+       // to resolve macros in it. This has nothing to do with
+       // labels, but by putting it here we avoid implementing
+       // a whole bunch of traversal routines just for this call.
+       parit.text()->setMacrocontextPosition(parit);
+
        depth_type maxdepth = 0;
        pit_type const lastpit = parit.lastpit();
        for ( ; parit.pit() <= lastpit ; ++parit.pit()) {