commit f180ab1f18f0dee052be413d52bf9d231fb9cc66
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Fri May 9 15:46:22 2025 +0200
Improve assertion for missing paragraph position
Use 0xdeadbeef as special position instead of -10000, which can
actually be achieved in real life.
Change top() and bottom() so that the validity of the position is
checked.
---
src/ParagraphMetrics.cpp | 2 +-
src/ParagraphMetrics.h | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/ParagraphMetrics.cpp b/src/ParagraphMetrics.cpp
index 464c088bfe..314bed7f61 100644
--- a/src/ParagraphMetrics.cpp
+++ b/src/ParagraphMetrics.cpp
@@ -40,7 +40,7 @@ using namespace lyx::support;
namespace lyx {
-const int pm_npos = -10000;
+const int pm_npos = 0xdeadbeef;
ParagraphMetrics::ParagraphMetrics(Paragraph const & par) :
position_(pm_npos), id_(par.id()), par_(&par)
diff --git a/src/ParagraphMetrics.h b/src/ParagraphMetrics.h
index ff5677dfa4..944307c856 100644
--- a/src/ParagraphMetrics.h
+++ b/src/ParagraphMetrics.h
@@ -86,9 +86,9 @@ public:
/// Return true when the position of the paragraph is known
bool hasPosition() const;
/// The vertical position of the top of the paragraph
- int top() const { return position_ - dim_.ascent(); }
+ int top() const { return position() - dim_.ascent(); }
/// The vertical position of the bottom of the paragraph
- int bottom() const { return position_ + dim_.descent(); }
+ int bottom() const { return position() + dim_.descent(); }
///
int id() const { return id_; }
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs