]> git.lyx.org Git - features.git/blobdiff - src/Buffer.cpp
Fix crash when closing master with children and grandchildren
[features.git] / src / Buffer.cpp
index 11e46ba0219230850edd3307b350824ecd071409..c4ce8ea053d45633e4ace7f8f3c4463e26047b14 100644 (file)
@@ -3720,8 +3720,12 @@ void Buffer::listMacroNames(MacroNameSet & macros) const
        // loop over children
        Impl::BufferPositionMap::iterator it = d->children_positions.begin();
        Impl::BufferPositionMap::iterator end = d->children_positions.end();
-       for (; it != end; ++it)
-               it->first->listMacroNames(macros);
+       for (; it != end; ++it) {
+               Buffer * child = const_cast<Buffer *>(it->first);
+               // The buffer might have been closed (see #10766).
+               if (theBufferList().isLoaded(child))
+                       child->listMacroNames(macros);
+       }
 
        // call parent
        Buffer const * const pbuf = d->parent();