summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--toolkit/source/controls/tree/treedatamodel.cxx21
1 files changed, 7 insertions, 14 deletions
diff --git a/toolkit/source/controls/tree/treedatamodel.cxx b/toolkit/source/controls/tree/treedatamodel.cxx
index 891525d9d913..292d68555dcf 100644
--- a/toolkit/source/controls/tree/treedatamodel.cxx
+++ b/toolkit/source/controls/tree/treedatamodel.cxx
@@ -436,23 +436,16 @@ void SAL_CALL MutableTreeNode::removeChildByIndex( sal_Int32 nChildIndex ) throw
{
::osl::Guard< ::osl::Mutex > aGuard( maMutex );
- MutableTreeNodeRef xImpl;
+ if( (nChildIndex < 0) || (nChildIndex >= (sal_Int32)maChildren.size()) )
+ throw IndexOutOfBoundsException();
- if( (nChildIndex >= 0) && (nChildIndex < (sal_Int32)maChildren.size()) )
- {
- TreeNodeVector::iterator aIter( maChildren.begin() );
- while( nChildIndex-- && (aIter != maChildren.end()) )
- ++aIter;
+ MutableTreeNodeRef xImpl;
- if( aIter != maChildren.end() )
- {
- xImpl = (*aIter);
- maChildren.erase( aIter );
- }
- }
+ TreeNodeVector::iterator aIter( maChildren.begin() );
+ std::advance(aIter, nChildIndex);
- if( !xImpl.is() )
- throw IndexOutOfBoundsException();
+ xImpl = (*aIter);
+ maChildren.erase( aIter );
xImpl->setParent(0);
xImpl->mbIsInserted = false;