Hi devels,<br><br>As you all have seen a <a href="http://reviewboard.kde.org/r/4285/">review request</a> about failed test, which was occuring due to use of QVector in GeoDataContainer. On append QVector rearranges itself to store all data in contiguous memory locations. So returning address of m_vector[i] may result in dangling pointer.<br>
<br>I came up with two solution to solve the problem we were facing :<br><ol><li>In GeoDataContainer replace QVector<GeoDataFeature> m_vector with QList<GeoDataFeature> m_vector</li><li>In GeoDataContainer replace QVector<GeoDataFeature> m_vector with QVector<GeoDataFeature *> m_vector</li>
</ol>In first method it would be tough to perform a quick switch
between the new api developed, so we have to make two parallel kind of
running thing(not sure what kind of thing it would be).<br><br>Second
way looks great to me with few small concerns. In this we don't need to
change the api, just api implementation will be changed from reference
based to pointer based which is quite easy but problem is only 4
functions. I am interested in knowing that whether these functions are
really important(to modify m_vector or just to read data from m_vector) or just added to follow the standards, these functions
are :<br>
<br>QVector<GeoDataFeature>::Iterator begin();<br><div id=":14x" class="ii gt"> QVector<GeoDataFeature>::Iterator end();<br> QVector<GeoDataFeature>::ConstIterator constBegin() const; <br> QVector<GeoDataFeature>::ConstIterator constEnd() const; //won't be modifying, so can el<br>
<br>last two won't be modifying, so can eleminate this by calling features() which will result in QVector() and then constBegin() and constEnd() for fetures().<br><br>But suggest me how can I implement begin() and end() if I replace QVector<GeoDataFeature> m_vector with
QVector<GeoDataFeature *> m_vector(which seems to be the perfect
way to remove the bug we are facing). The main thing is I don't want to change the API, I just want to change the implementation so others won't get affected.<br>
<br>What are your suggestions about the above two approaches.</div><br clear="all"><br>-- <br>Gaurav Gupta<br>Final Year Undergraduate<br>IT BHU<br>GSOC 10 KDE marble<br><a href="http://techespanto.wordpress.com/">http://techespanto.wordpress.com/</a><br>
<a href="http://gitorious.org/~1989gaurav">http://gitorious.org/~1989gaurav</a><br>