[Marble-commits] KDE/kdeedu/marble/src/lib
Jens-Michael Hoffmann
jensmh at gmx.de
Mon Jul 13 15:27:33 CEST 2009
Am Saturday 11 July 2009 17:53:35 schrieb Patrick Spendrin:
> SVN commit 994886 by sengels:
>
> use the vector directly to get the correct end-iterator
>
> M +6 -5 MarbleGeometryModel.cpp
>
>
> --- trunk/KDE/kdeedu/marble/src/lib/MarbleGeometryModel.cpp #994885:994886
> @@ -51,11 +51,12 @@
> if( !geometry ) return;
>
> GeoDataMultiGeometry* multiGeometry = static_cast<GeoDataMultiGeometry*>( geometry );
> - QVector<GeoDataGeometry>::iterator iterator = multiGeometry->begin();
> - QVector<GeoDataGeometry>::iterator end = multiGeometry->end();
> - for(; iterator != end; ++iterator ) {
> - m_parent.insert( &( *iterator ), geometry );
> - if( iterator->geometryId() == GeoDataMultiGeometryId ) mapGeometry( &( *iterator ) );
> + QVector<GeoDataGeometry>::iterator iterator = multiGeometry->vector().begin();
> + QVector<GeoDataGeometry>::iterator end = multiGeometry->vector().end();
that's quite dangerous, you might end up with the wrong end iterator here. Better is
QVector<GeoDataGeometry> & vec = multiGeometry->vector();
QVector<GeoDataGeometry>::iterator pos = vec.begin();
QVector<GeoDataGeometry>::iterator end = vec.end();
> +
> + for(; iterator != end; iterator++ ) {
here prefix increment would be better since it does not create a temporary.
> + m_parent.insert( iterator, geometry );
> + if( iterator->geometryId() == GeoDataMultiGeometryId ) mapGeometry( iterator );
> }
> };
>
> _______________________________________________
> Marble-commits mailing list
> Marble-commits at kde.org
> https://mail.kde.org/mailman/listinfo/marble-commits
>
More information about the Marble-commits
mailing list