[Kstars-devel] GSoC progress : QList index out of range

Jasem Mutlaq mutlaqja at ikarustech.com
Mon Jun 15 22:39:36 UTC 2015


Adityan,

Commit your code and I'll check your branch tomorrow to diagnose the issue.
Btw, the midterm evaluations are coming up soon, so please try to work hard
in this period as the skeleton needs to be ready by June 26th. Same goes
for Daniel with the Ekos scheduler. I realize you folks have exams, so try
to manage your time accordingly.

Regards,
Jasem


On Sun, Jun 14, 2015 at 4:52 PM, M.S. Adityan <msadityan at gmail.com> wrote:

> Hi,
>
> 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.
>
> ASSERT failure in QList<T>::operator[]: "index out of range", file
> /usr/include/x86_64-linux-gnu/qt5/QtCore/qlist.h, line 487
> Aborted (core dumped)
>
> Here is the code for constartcomponent.h
>
> #ifndef CONSTARTCOMPONENT_H
> #define CONSTARTCOMPONENT_H
>
> #include "constellationsart.h"
>
> class ConstellationsArt;
>
> class ConstArtComponent
> {
> public:
>     ConstArtComponent();
>     ~ConstArtComponent();
>
>     //Outputs details of the QList
>     void showList();
>
>     QList<ConstellationsArt> c_list;
> };
>
> #endif // CONSTARTCOMPONENT_H
>
> Here is the code for constartcomponent.cpp
>
> #include "constartcomponent.h"
> #include "kstars/auxiliary/ksfilereader.h"
>
> ConstArtComponent::ConstArtComponent()
> {
>     int i = 0;
>
>     // Find constellation art file and open it. If it doesn't exist,
> output an error message.
>     KSFileReader fileReader;
>     if ( ! fileReader.open("constellationsart.txt" ) )
>     {
>         qDebug() << "No constellationsart.txt file found for sky culture";
>         return;
>     }
>
>     while ( fileReader.hasMoreLines() ) {
>         QString line;
>
>         line = fileReader.readLine();
>         if( line.isEmpty() )
>             continue;
>         QChar mode = line.at( 0 );
>         //ignore lines beginning with "#":
>         if( mode == '#' )
>             continue;
>
>         //reads the first column from constellationart.txt
>         c_list[i].rank = line.mid(0,2).trimmed().toInt();
>
>         //Read pixel coordinates and HD number of star 1
> //This works because ConstArtComponent is a fried class of
> ConstellationsArt
>         c_list[i].x1 = line.mid( 3, 3 ).trimmed().toInt();
>         c_list[i].y1 = line.mid( 7, 3 ).trimmed().toInt();
>         c_list[i].hd1 = line.mid( 11, 6 ).trimmed().toInt();
>
>         //Read pixel coordinates and HD number of star 2
>         c_list[i].x2 = line.mid( 18, 3 ).trimmed().toInt();
>         c_list[i].y2 = line.mid( 22, 3 ).trimmed().toInt();
>         c_list[i].hd2 = line.mid( 26, 6 ).trimmed().toInt();
>
>         //Read pixel coordinates and HD number of star 3
>         c_list[i].x3 = line.mid( 33, 3 ).trimmed().toInt();
>         c_list[i].y3 = line.mid( 37, 3 ).trimmed().toInt();
>         c_list[i].hd3 = line.mid( 41, 6 ).trimmed().toInt();
>
>         //Read abbreviation and image file name
>         c_list[i].abbrev = line.mid( 48, 3 );
>         c_list[i].imageFileName  = line.mid( 52 ).trimmed();
>
>         //Make a QImage object pointing to constellation image
>         c_list[i].c_image = QImage(c_list[i].imageFileName,0);
>         i++;
>
>         }
> }
> ConstArtComponent::~ConstArtComponent()
> {
>
> }
>
> void ConstArtComponent::showList()
> {
>     int i = 0;
>     for(i = 0; i < c_list.size(); i++)
>     {
>         qDebug()<<c_list[i].getx1();
>     }
> }
>
> This is what I am doing ConstArtComponent obj; obj.showList();
>
> I am not able to figure out where i am accessing an index that is out of
> range. Can anyone help me with this?
>
> Regards
> M.S.Adityan
> Website: www.msadityan.com
> https://www.linkedin.com/in/msadityan
>
> _______________________________________________
> Kstars-devel mailing list
> Kstars-devel at kde.org
> https://mail.kde.org/mailman/listinfo/kstars-devel
>
>


-- 
Best Regards,
Jasem Mutlaq
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kstars-devel/attachments/20150616/29cf32d1/attachment.html>


More information about the Kstars-devel mailing list