commit ac8948b8e00c4b517a117cc36b01b696def668c1
Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date:   Fri Mar 12 17:37:31 2021 +0100

    Fixup 86bfa10a: add checks before updating bookmarks
    
    When doing cut and paste, it can happen that inset_owner_ is null, or
    that the inset is not related to a buffer.
---
 src/Paragraph.cpp |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 8ac87d3..6bf4ce3 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -835,8 +835,9 @@ void Paragraph::Private::insertChar(pos_type pos, char_type 
c,
        speller_state_.increasePosAfterPos(pos);
 
        // Update bookmarks
-       
theSession().bookmarks().adjustPosAfterPos(inset_owner_->buffer().fileName(),
-                                                  id_, pos, 1);
+       if (inset_owner_ && inset_owner_->isBufferValid())
+               
theSession().bookmarks().adjustPosAfterPos(inset_owner_->buffer().fileName(),
+                                                      id_, pos, 1);
 }
 
 
@@ -922,8 +923,9 @@ bool Paragraph::eraseChar(pos_type pos, bool trackChanges)
        d->speller_state_.refreshLast(size());
 
        // Update bookmarks
-       
theSession().bookmarks().adjustPosAfterPos(d->inset_owner_->buffer().fileName(),
-                                                  d->id_, pos, -1);
+       if (d->inset_owner_ && d->inset_owner_->isBufferValid())
+               
theSession().bookmarks().adjustPosAfterPos(d->inset_owner_->buffer().fileName(),
+                                                      d->id_, pos, -1);
 
        return true;
 }
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to