Hi Guys,
I declared a QFile* and QTextStream* pointers in a class called HistoricalInfo, then I instantiated them and the following function:
int HistoricalInfo
::Load(const QString & strFilename
) {
file = new QFile(strFilename
);
//create new file, attached to a file name
reader
= new QTextStream(file);
//point reader to the file
if (!file->open(IO_ReadOnly | IO_Translate)) //test that file is opens sucessfully
{
errno = ENOENT; //exit if not opened correctly
return 0;
}
reader->setDevice(file); //set device
...
}
int HistoricalInfo::Load(const QString & strFilename)
{
file = new QFile(strFilename); //create new file, attached to a file name
reader = new QTextStream(file); //point reader to the file
if (!file->open(IO_ReadOnly | IO_Translate)) //test that file is opens sucessfully
{
errno = ENOENT; //exit if not opened correctly
return 0;
}
reader->setDevice(file); //set device
...
}
To copy to clipboard, switch view to plain text mode
Then, I call following function (HistricalData_Read()) ), which was called by another function ...
void HistoricalInfo::HistoricData_Read()
{
while (!(line = reader->readLine()).isNull()) //read lines from the file until there is no more data
{
if (line.isEmpty()) //if line is empty then go to the next line
continue;
if(line == "*") //if line is a star(delimiter) then ...
{ //we have found a whole data set then break
break;
}
if(!Extractinfo(line, recSpeed)) //we can parse the line
printf("error occured while extracting historical data\n"); //or error out!
}
LoadHistoricalinfo(); //load segement data into a list
}
void HistoricalInfo::HistoricData_Read()
{
QString line;
while (!(line = reader->readLine()).isNull()) //read lines from the file until there is no more data
{
if (line.isEmpty()) //if line is empty then go to the next line
continue;
if(line == "*") //if line is a star(delimiter) then ...
{ //we have found a whole data set then break
break;
}
if(!Extractinfo(line, recSpeed)) //we can parse the line
printf("error occured while extracting historical data\n"); //or error out!
}
LoadHistoricalinfo(); //load segement data into a list
}
To copy to clipboard, switch view to plain text mode
I keep getting a segmentation fault in the
while (!(line = reader->readLine()).isNull()) ..line.
while (!(line = reader->readLine()).isNull()) ..line.
To copy to clipboard, switch view to plain text mode
Can anyone please help me ?
Bookmarks