From: Kimmo Hoikka Date: Wed, 23 Jul 2014 13:29:03 +0000 (+0100) Subject: Fix regression in debug build & test cases X-Git-Tag: dali_1.0.1~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F60%2F24860%2F1;p=platform%2Fcore%2Fuifw%2Fdali-core.git Fix regression in debug build & test cases [Problem] index going out of bounds [Cause] using wrong method [Solution] correct algorithm Change-Id: I2cd31458534fa8886b7ff27e711fe65e161a1b50 --- diff --git a/dali/public-api/signals/base-signal.cpp b/dali/public-api/signals/base-signal.cpp index cb21f43..71ff408 100644 --- a/dali/public-api/signals/base-signal.cpp +++ b/dali/public-api/signals/base-signal.cpp @@ -289,18 +289,21 @@ void BaseSignal::CleanupConnections() // only do something if there are items if( total > 0 ) { - std::size_t removed = 0; + std::size_t index = 0; + // process the whole vector for( std::size_t i = 0; i < total; ++i ) { - if( mSignalConnections[ i ] == NULL ) + if( mSignalConnections[ index ] == NULL ) { - ++removed; - // swaps it to the end - mSignalConnections.Remove( mSignalConnections.Begin() + i ); + // items will be moved so don't increase index (erase will decrease the count of vector) + mSignalConnections.Erase( mSignalConnections.Begin() + index ); + } + else + { + // increase to next element + ++index; } } - // dont reallocate memory, just resize vector - mSignalConnections.Resize( total - removed ); } }