Kaydet (Commit) 594733a5 authored tarafından Takeshi Abe's avatar Takeshi Abe Kaydeden (comit) Caolán McNamara

starmath: Assert FindIndex()'s precondition

by using std::assert rather thatn DBG_ASSERT.

Change-Id: I8fca2b82f8d86a843c024556a0a29c7848b1e602
Reviewed-on: https://gerrit.libreoffice.org/19294Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 2bd26bfc
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <tools/gen.hxx> #include <tools/gen.hxx>
#include <vcl/outdev.hxx> #include <vcl/outdev.hxx>
#include <cassert>
#include <math.h> #include <math.h>
#include <float.h> #include <float.h>
#include <vector> #include <vector>
...@@ -259,16 +260,15 @@ void SmNode::Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell) ...@@ -259,16 +260,15 @@ void SmNode::Prepare(const SmFormat &rFormat, const SmDocShell &rDocShell)
sal_uInt16 SmNode::FindIndex() const sal_uInt16 SmNode::FindIndex() const
{ {
const SmStructureNode* pParent = GetParent(); assert(mpParentNode != nullptr && "FindIndex() requires this is a subnode.");
if (!pParent) { return 0; }
for (sal_uInt16 i = 0; i < pParent->GetNumSubNodes(); ++i) { for (sal_uInt16 i = 0; i < mpParentNode->GetNumSubNodes(); ++i) {
if (pParent->GetSubNode(i) == this) { if (mpParentNode->GetSubNode(i) == this) {
return i; return i;
} }
} }
DBG_ASSERT(false, "Connection between parent and child is inconsistent."); assert(false && "Connection between parent and child is inconsistent.");
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment