Fix crash when closing master with children and grandchildren

In some cases, it is possible that the BufferPositionMap has
dangling pointers. We thus check whether the Buffer is loaded
before accessing it.

Fixes: #10766
(cherry picked from commit 4f50cbcfe4)
This commit is contained in:
Juergen Spitzmueller 2017-09-28 09:06:33 +02:00
parent 1d55d8cd25
commit 7b41d977ad
2 changed files with 9 additions and 2 deletions

View File

@ -3583,8 +3583,12 @@ void Buffer::listMacroNames(MacroNameSet & macros) const
// loop over children // loop over children
Impl::BufferPositionMap::iterator it = d->children_positions.begin(); Impl::BufferPositionMap::iterator it = d->children_positions.begin();
Impl::BufferPositionMap::iterator end = d->children_positions.end(); Impl::BufferPositionMap::iterator end = d->children_positions.end();
for (; it != end; ++it) for (; it != end; ++it) {
it->first->listMacroNames(macros); Buffer * child = const_cast<Buffer *>(it->first);
// The buffer might have been closed (see #10766).
if (theBufferList().isLoaded(child))
child->listMacroNames(macros);
}
// call parent // call parent
Buffer const * const pbuf = d->parent(); Buffer const * const pbuf = d->parent();

View File

@ -78,6 +78,9 @@ What's new
- Fix crash when closing master document with dirty child while Document - Fix crash when closing master document with dirty child while Document
Settings dialog is open (bug 9979). Settings dialog is open (bug 9979).
- Fix crash when closing master with children and grandchildren
(bug 10766).
- Fix random crash when dissolving inset (bug 10667). - Fix random crash when dissolving inset (bug 10667).
- Fix potential crash when cursor enters an inset (bug 10691). - Fix potential crash when cursor enters an inset (bug 10691).