]> git.lyx.org Git - features.git/commitdiff
More comments and minor cleanup
authorRichard Kimberly Heck <rikiheck@lyx.org>
Mon, 9 Nov 2020 21:36:20 +0000 (16:36 -0500)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Mon, 9 Nov 2020 21:36:20 +0000 (16:36 -0500)
src/Buffer.cpp

index 7237737dad9f531e98c24954fab61b994a10cc52..66654516d379cfe1627b14ff79ef9778280279ed 100644 (file)
@@ -213,18 +213,21 @@ public:
        /// which maps the macro definition position to the scope and the MacroData.
        NamePositionScopeMacroMap macros;
 
-       /// positions of child buffers in the buffer
+       /// Each child Buffer is listed in this map, together with where
+       /// it is included in this Buffer.
+       typedef map<Buffer const * const, DocIterator> BufferPositionMap;
+       BufferPositionMap children_positions;
+       /// We also have a map from the positions where Buffers are included
+       /// to those Buffers and their scope (whose point RKH does not yet 
+       /// understand).
+       // FIXME Surely one of these is enough?
        struct ScopeBuffer {
-               ScopeBuffer() : buffer(nullptr) {}
+               ScopeBuffer() = default;
                ScopeBuffer(DocIterator const & s, Buffer const * b)
                        : scope(s), buffer(b) {}
                DocIterator scope;
                Buffer const * buffer;
        };
-       /// position of children buffers in this buffer
-       typedef map<Buffer const * const, DocIterator> BufferPositionMap;
-       BufferPositionMap children_positions;
-       /// map from children inclusion positions to their scope and their buffer
        typedef map<DocIterator, ScopeBuffer> PositionScopeBufferMap;
        PositionScopeBufferMap position_to_children;
 
@@ -5465,9 +5468,9 @@ bool Buffer::saveAs(FileName const & fn)
 
 void Buffer::checkChildBuffers()
 {
-       for (auto const & bit : d->children_positions) {
-               DocIterator dit = bit.second;
-               Buffer * cbuf = const_cast<Buffer *>(bit.first);
+       for (auto const & kid : d->children_positions) {
+               DocIterator const & dit = kid.second;
+               Buffer * cbuf = const_cast<Buffer *>(kid.first);
                if (!cbuf || !theBufferList().isLoaded(cbuf))
                        continue;
                Inset * inset = dit.nextInset();
@@ -5479,7 +5482,9 @@ void Buffer::checkChildBuffers()
                                onlyPath(absFileName())).absFileName();
                if (oldloc == newloc)
                        continue;
-               // the location of the child file is incorrect.
+               // the location of the child file is incorrect. e.g., it
+               // had a relative path which does not now point to the correct
+               // file (after saveAs, usually).
                cbuf->setParent(nullptr);
                inset_inc->setChildBuffer(nullptr);
        }