[Libreoffice-commits] core.git: starmath/inc starmath/source
Takeshi Abe
tabe at fixedpoint.jp
Tue Dec 27 18:29:42 UTC 2016
starmath/inc/caret.hxx | 7 ++++++-
starmath/source/caret.cxx | 2 +-
2 files changed, 7 insertions(+), 2 deletions(-)
New commits:
commit 95d47fbf4110a81af9776edc6da387d9189abfa4
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date: Tue Dec 27 19:14:37 2016 +0900
starmath: SmCaretPos's index must be non-negative
Change-Id: I69a2fc0c9ccaa76a0d93127ac6a1544fe9924605
Reviewed-on: https://gerrit.libreoffice.org/32444
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Takeshi Abe <tabe at fixedpoint.jp>
diff --git a/starmath/inc/caret.hxx b/starmath/inc/caret.hxx
index 113ab8f..a1d12cd 100644
--- a/starmath/inc/caret.hxx
+++ b/starmath/inc/caret.hxx
@@ -15,6 +15,7 @@
#include "node.hxx"
+#include <cassert>
#include <memory>
#include <vector>
@@ -24,10 +25,13 @@ struct SmCaretPos{
: pSelectedNode(selectedNode)
, nIndex(iIndex)
{
+ assert(nIndex >= 0);
}
+
/** Selected node */
SmNode* pSelectedNode;
- /** Index within the selected node
+
+ /** Index (invariant: non-negative) within the selected node
*
* 0: Position in front of a node
* 1: Position after a node or after first char in SmTextNode
@@ -38,6 +42,7 @@ struct SmCaretPos{
//TODO: Special cases for SmBlankNode is needed
//TODO: Consider forgetting about the todo above... As it's really unpleasant.
int nIndex;
+
/** True, if this is a valid caret position */
bool IsValid() const { return pSelectedNode != nullptr; }
bool operator==(const SmCaretPos &pos) const {
diff --git a/starmath/source/caret.cxx b/starmath/source/caret.cxx
index 3504ec8..6c1c974 100644
--- a/starmath/source/caret.cxx
+++ b/starmath/source/caret.cxx
@@ -17,7 +17,7 @@ SmCaretPosGraph::~SmCaretPosGraph() = default;
SmCaretPosGraphEntry* SmCaretPosGraph::Add(SmCaretPos pos,
SmCaretPosGraphEntry* left)
{
- SAL_WARN_IF( pos.nIndex < 0, "starmath", "nIndex shouldn't be -1!" );
+ assert(pos.nIndex >= 0);
auto entry = o3tl::make_unique<SmCaretPosGraphEntry>(pos, left, nullptr);
SmCaretPosGraphEntry* e = entry.get();
//Set Left and Right to point to the entry itself if they are NULL
More information about the Libreoffice-commits
mailing list