summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--svtools/source/contnr/treelist.cxx11
1 files changed, 8 insertions, 3 deletions
diff --git a/svtools/source/contnr/treelist.cxx b/svtools/source/contnr/treelist.cxx
index 2ec20bd0dea9..ea451b6178d9 100644
--- a/svtools/source/contnr/treelist.cxx
+++ b/svtools/source/contnr/treelist.cxx
@@ -1751,9 +1751,14 @@ void SvTreeList::ResortChildren( SvTreeListEntry* pParent )
SvTreeListEntry* p = *it;
sal_uLong nListPos = ULONG_MAX;
GetInsertionPos(p, pParent, nListPos);
- SvTreeListEntries::iterator itPos = pParent->maChildren.begin();
- std::advance(itPos, nListPos);
- pParent->maChildren.insert(itPos, p);
+ if (nListPos < pParent->maChildren.size())
+ {
+ SvTreeListEntries::iterator itPos = pParent->maChildren.begin();
+ std::advance(itPos, nListPos);
+ pParent->maChildren.insert(itPos, p);
+ }
+ else
+ pParent->maChildren.push_back(p);
if (!p->maChildren.empty())
// Recursively sort child entries.
ResortChildren(p);