Le 14/01/2018 à 19:42, Pavel Sanda a écrit :
Pavel Sanda wrote:
Still trying.
Bisect leads to:
commit 02028c0b12ba94093e4e77494e7158a58f1631e5
Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date: Sun Jul 23 18:13:33 2017 +0200
Move some Cursor methods to CursorData
I cannot reproduce, but here is a candidate patch for fixing
Cursor::sanitize.
Please test. I have done other changes for enforcing encapsulation
between CursorData and Cursor.
JMarc
From 5ce9e65a09ce9a72ab9bb173d92366b902211ee4 Mon Sep 17 00:00:00 2001
From: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date: Tue, 16 Jan 2018 16:00:07 +0100
Subject: [PATCH] Fix Cursor::sanitize
This is a follow-up to 02028c0b12ba9.
Fix two bugs introduced when moving Cursor::sanitize() to CursorData:
* the setBuffer that is supposed to set buffer from bufferview became
a no-op.
* new_word_ is now part of CursorData, but it is sanitized only in
Cursor::sanitize().
Additionally, make all protected CursorData data members private to enforce
encapsulation.
---
src/Cursor.cpp | 14 +++++++-------
src/Cursor.h | 25 +++++++++++--------------
2 files changed, 18 insertions(+), 21 deletions(-)
diff --git a/src/Cursor.cpp b/src/Cursor.cpp
index 3f5bff8..a3fb0c0 100644
--- a/src/Cursor.cpp
+++ b/src/Cursor.cpp
@@ -121,19 +121,19 @@ DocIterator bruteFind(Cursor const & c, int x, int y)
CursorData::CursorData()
: DocIterator(), anchor_(), selection_(false), mark_(false),
- word_selection_(false), current_font(inherit_font), autocorrect_(false)
+ word_selection_(false), autocorrect_(false), current_font(inherit_font)
{}
CursorData::CursorData(Buffer * buffer)
: DocIterator(buffer), anchor_(), selection_(false), mark_(false),
- word_selection_(false), current_font(inherit_font), autocorrect_(false)
+ word_selection_(false), autocorrect_(false), current_font(inherit_font)
{}
CursorData::CursorData(DocIterator const & dit)
: DocIterator(dit), anchor_(), selection_(false), mark_(false),
- word_selection_(false), current_font(inherit_font), autocorrect_(false)
+ word_selection_(false), autocorrect_(false), current_font(inherit_font)
{}
@@ -515,6 +515,7 @@ bool CursorData::fixIfBroken()
void CursorData::sanitize()
{
DocIterator::sanitize();
+ new_word_.sanitize();
if (selection())
anchor_.sanitize();
else
@@ -1388,9 +1389,9 @@ bool Cursor::openable(MathAtom const & t) const
return true;
// we can't move into anything new during selection
- if (depth() >= anchor_.depth())
+ if (depth() >= realAnchor().depth())
return false;
- if (t.nucleus() != &anchor_[depth()].inset())
+ if (t.nucleus() != &realAnchor()[depth()].inset())
return false;
return true;
@@ -2293,9 +2294,8 @@ Font Cursor::getFont() const
void Cursor::sanitize()
{
- setBuffer(buffer());
+ setBuffer(&bv_->buffer());
CursorData::sanitize();
- new_word_.sanitize();
}
diff --git a/src/Cursor.h b/src/Cursor.h
index 6c5e5e6..c028adf 100644
--- a/src/Cursor.h
+++ b/src/Cursor.h
@@ -47,8 +47,7 @@ global.
deriving from DocIterator
* A Cursor is a descendant of CursorData that contains interesting
- display-related information, in particular targetX(), the horizontal
- position of the cursor in pixels.
+ display-related information, in particular the BufferView that owns it.
*/
#ifndef LCURSOR_H
@@ -138,7 +137,6 @@ public:
DocIterator & realAnchor() { return anchor_; }
/// sets anchor to cursor position
void resetAnchor();
- /// access to owning BufferView
/// access start of selection
CursorSlice selBegin() const;
@@ -216,7 +214,7 @@ public:
/// one inset in the selection has confirmDeletion.
bool confirmDeletion(bool before = false) const;
-protected:
+private:
/// validate the "new born word" position
void checkNewWordPosition();
/// clear the "new born word" position
@@ -231,15 +229,6 @@ protected:
/// are we in word-selection mode? This is set when double clicking.
bool word_selection_;
-// FIXME: make them protected.
-public:
- /// the current font settings
- Font current_font;
- /// the current font
- Font real_current_font;
-
-protected:
-
/// the start of the new born word
DocIterator new_word_;
//
@@ -247,6 +236,13 @@ protected:
//
/// do we allow autocorrection
bool autocorrect_;
+
+ // FIXME: make them private
+public:
+ /// the current font settings
+ Font current_font;
+ /// the current font
+ Font real_current_font;
};
@@ -380,6 +376,7 @@ public:
/// distance between actual and targeted position during last up/down in text
int textTargetOffset() const;
+ /// access to owning BufferView
BufferView & bv() const;
/// reset cursor bottom to the beginning of the top inset
// (sort of 'chroot' environment...)
@@ -549,4 +546,4 @@ bool notifyCursorLeavesOrEnters(Cursor const & old, Cursor & cur);
} // namespace lyx
-#endif // LYXLCURSOR_H
+#endif // LCURSOR_H
--
2.7.4