Comment 2 for bug 1173355

Revision history for this message
Emmanuel (hacker-emmanuel) wrote :

There is what looks like an actual memory handling error in the code that explains the three last failed assertions as well as the spherical cap not rendering properly.

This is in these excerpts of StelSphereGeometry.cpp and OctahedronPolygon.hpp:

 760 void SphericalRegion::updateFillVertexBuffer(StelRenderer* renderer, const DrawParams& params, bool handleDiscontinuity)
 761 {
 762 const QVector<Vec3d> &vertices = getOctahedronPolygon().fillVertices ();

1337 OctahedronPolygon SphericalCap::getOctahedronPolygon() const
1338 {
1339 if (d>=0)
1340 return OctahedronPolygon(getClosedOutlineContour());

113 //! Get vertices forming triangles filling out the polygon.
114 const QVector<Vec3d>& fillVertices() const
115 {
116 return fillCachedVertexArray;

160 //! Vertex array storing triangles of the polygon (each 3 vertices b eing one triangle).
161 QVector<Vec3d> fillCachedVertexArray;

=> vertices is defined as a reference to a field of a temporary OctahedronPolygon object that gets destroyed right after the definition of 'vertices'
=> in the rest of the SphericalRegion::updateFillVertexBuffer() method it is not legit to use 'vertices', but that's what is done, and why it sometimes crashes

Replacing:
 762 const QVector<Vec3d> &vertices = getOctahedronPolygon().fillVertices ();
With:
 762 const QVector<Vec3d> vertices = getOctahedronPolygon().fillVertices ();
solves the issue (but that's just to demonstrate the problem, not an optimal solution)

The initial issue of the first assertion that fails in debug mode remains though.