]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
Fix a crash when closing tabs
[lyx.git] / src / Buffer.cpp
index f2a370235a1374997b25903cae402c2c23ea0904..5c7b88682b1e0e041f841ea92af61ebbcf2b8b30 100644 (file)
@@ -2944,7 +2944,9 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
                                undo().recordUndoBufferParams(CursorData());
                                branch_list.add(branch_name);
                                branch = branch_list.find(branch_name);
-                               branch->setColors("background", "background");
+                               if (branch)
+                                       // needed to update the color table for dark mode
+                                       branch->setColors("background", "background");
                                dr.setError(false);
                                dr.screenUpdate(Update::Force);
                        }
@@ -3536,6 +3538,9 @@ void Buffer::collectChildren(ListOfBuffers & children, bool grand_children) cons
        // loop over children
        for (auto const & p : d->children_positions) {
                Buffer * child = const_cast<Buffer *>(p.first);
+               // This can happen when called during GUI operations
+               if (!theBufferList().isLoaded(child))
+                       continue;
                // No duplicates
                ListOfBuffers::const_iterator bit = find(children.begin(), children.end(), child);
                if (bit != children.end())
@@ -5007,6 +5012,8 @@ void Buffer::updateBuffer(UpdateScope scope, UpdateType utype) const
        cbuf.tocBackend().update(true, utype);
        if (scope == UpdateMaster)
                cbuf.structureChanged();
+
+       d->need_update = false;
 }