<div dir="ltr"><div><div><div><div><div>Hi,<br><br></div>I have added another class called ConstArtComponent. This class contains a QList of ConstellationsArt objects. This QList will hold all the data required for a Constellation Image. Currently this QList will hold 88 members, corresponding to 88 western constellations. We can add more QLists corresponding to different sky cultures at a later point of time. KStars compiles perfectly, but I get this error when I run KStars.<br><br>ASSERT failure in QList<T>::operator[]: "index out of range", file /usr/include/x86_64-linux-gnu/qt5/QtCore/qlist.h, line 487<br>Aborted (core dumped)<br><br></div>Here is the code for constartcomponent.h<br><br>#ifndef CONSTARTCOMPONENT_H<br>#define CONSTARTCOMPONENT_H<br><br>#include "constellationsart.h"<br><br>class ConstellationsArt;<br><br>class ConstArtComponent<br>{<br>public:<br> ConstArtComponent();<br> ~ConstArtComponent();<br><br> //Outputs details of the QList<br> void showList();<br><br> QList<ConstellationsArt> c_list;<br>};<br><br>#endif // CONSTARTCOMPONENT_H<br><br></div>Here is the code for constartcomponent.cpp<br><br>#include "constartcomponent.h"<br>#include "kstars/auxiliary/ksfilereader.h"<br><br>ConstArtComponent::ConstArtComponent()<br>{<br> int i = 0;<br><br> // Find constellation art file and open it. If it doesn't exist, output an error message.<br> KSFileReader fileReader;<br> if ( ! fileReader.open("constellationsart.txt" ) )<br> {<br> qDebug() << "No constellationsart.txt file found for sky culture";<br> return;<br> }<br><br> while ( fileReader.hasMoreLines() ) {<br> QString line;<br><br> line = fileReader.readLine();<br> if( line.isEmpty() )<br> continue;<br> QChar mode = <a href="http://line.at">line.at</a>( 0 );<br> //ignore lines beginning with "#":<br> if( mode == '#' )<br> continue;<br><br> //reads the first column from constellationart.txt<br> c_list[i].rank = line.mid(0,2).trimmed().toInt();<br><br> //Read pixel coordinates and HD number of star 1<br>//This works because ConstArtComponent is a fried class of ConstellationsArt<br> c_list[i].x1 = line.mid( 3, 3 ).trimmed().toInt(); <br> c_list[i].y1 = line.mid( 7, 3 ).trimmed().toInt();<br> c_list[i].hd1 = line.mid( 11, 6 ).trimmed().toInt();<br><br> //Read pixel coordinates and HD number of star 2<br> c_list[i].x2 = line.mid( 18, 3 ).trimmed().toInt();<br> c_list[i].y2 = line.mid( 22, 3 ).trimmed().toInt();<br> c_list[i].hd2 = line.mid( 26, 6 ).trimmed().toInt();<br><br> //Read pixel coordinates and HD number of star 3<br> c_list[i].x3 = line.mid( 33, 3 ).trimmed().toInt();<br> c_list[i].y3 = line.mid( 37, 3 ).trimmed().toInt();<br> c_list[i].hd3 = line.mid( 41, 6 ).trimmed().toInt();<br><br> //Read abbreviation and image file name<br> c_list[i].abbrev = line.mid( 48, 3 );<br> c_list[i].imageFileName = line.mid( 52 ).trimmed();<br><br> //Make a QImage object pointing to constellation image<br> c_list[i].c_image = QImage(c_list[i].imageFileName,0);<br> i++;<br><br> }<br>}<br>ConstArtComponent::~ConstArtComponent()<br>{<br><br>}<br><br>void ConstArtComponent::showList()<br>{<br> int i = 0;<br> for(i = 0; i < c_list.size(); i++)<br> {<br> qDebug()<<c_list[i].getx1();<br> }<br>}<br><br></div>This is what I am doing ConstArtComponent obj; obj.showList();<br><br></div>I am not able to figure out where i am accessing an index that is out of range. Can anyone help me with this?<br><div><div><div><div><div><div><br></div><div>Regards<br clear="all"></div><div><div><div><div><div class="gmail_signature"><div dir="ltr"><div><div>M.S.Adityan</div><div dir="ltr">Website: <a href="http://www.msadityan.com" target="_blank">www.msadityan.com</a><div><a href="https://www.linkedin.com/in/msadityan" target="_blank">https://www.linkedin.com/in/msadityan</a><br></div></div></div></div></div></div>
</div></div></div></div></div></div></div></div></div>