[Marble-devel] GeoDataContainer API : Change API to Pointer based
gaurav gupta
1989.gaurav at googlemail.com
Mon Jun 21 12:10:08 CEST 2010
Hi devels,
As you all have seen a review request
<http://reviewboard.kde.org/r/4285/>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.
I came up with two solution to solve the problem we were facing :
1. In GeoDataContainer replace QVector<GeoDataFeature> m_vector with
QList<GeoDataFeature> m_vector
2. In GeoDataContainer replace QVector<GeoDataFeature> m_vector with
QVector<GeoDataFeature *> m_vector
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).
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 :
QVector<GeoDataFeature>::Iterator begin();
QVector<GeoDataFeature>::Iterator end();
QVector<GeoDataFeature>::ConstIterator constBegin() const;
QVector<GeoDataFeature>::ConstIterator constEnd() const; //won't be
modifying, so can el
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().
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.
What are your suggestions about the above two approaches.
--
Gaurav Gupta
Final Year Undergraduate
IT BHU
GSOC 10 KDE marble
http://techespanto.wordpress.com/
http://gitorious.org/~1989gaurav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/marble-devel/attachments/20100621/f2147299/attachment.htm
More information about the Marble-devel
mailing list