I keep getting segmentation fault and file not opened error ? Can anyone help ?
int HistoricalInfo
::Load(const QString & strFilename
) {
QFile file(strFilename
);
//IODevice
reader.setDevice(&file);
h_strFilename = strFilename; //save the file name
if (!file.open(IO_ReadOnly | IO_Translate))
{
errno = ENOENT;
return 0;
}
else
{
printf("File opened successfully \n");
}
if (g_pMainWindow != NULL && g_pMainWindow->m_pLblStatus != NULL)
g_pMainWindow->m_pLblStatus->setText("Loading Historical Info...");
g_pMainWindow->m_pPlayback = new QPlayback(g_pMainWindow->tabsContainer, "playback");
g_pMainWindow
->tabsWidget
->addTab
(g_pMainWindow
->m_pPlayback,
QString("Playback"));
g_pMainWindow->m_pPlayback->SetPlaybackInitialized(true);
return 1;
}
void HistoricalInfo
::HistoricData_Read(QTextStream & reader
) {
while (!(line = reader.readLine()).isNull())
{
if (line.isEmpty())
continue; //skip the next if, go to while
if(line == "*")
{
break;
}
if(!Extractinfo(line, recSpeed))
printf("error occured while extracting historical data\n");
}
LoadHistoricalinfo(); //load segement data into a list
}
void QPlayback:: signalPlay()
{
g_pMainWindow->m_pHist->HistoricData_Read(g_pMainWindow->m_pHist->reader); ///**************
ptrModelV->paintEvent(e); //refresh map
printf("PAINTING \n");
}
int HistoricalInfo::Load(const QString & strFilename)
{
QFile file(strFilename); //IODevice
reader.setDevice(&file);
h_strFilename = strFilename; //save the file name
if (!file.open(IO_ReadOnly | IO_Translate))
{
errno = ENOENT;
return 0;
}
else
{
printf("File opened successfully \n");
}
if (g_pMainWindow != NULL && g_pMainWindow->m_pLblStatus != NULL)
g_pMainWindow->m_pLblStatus->setText("Loading Historical Info...");
g_pMainWindow->m_pPlayback = new QPlayback(g_pMainWindow->tabsContainer, "playback");
g_pMainWindow->tabsWidget->addTab(g_pMainWindow->m_pPlayback, QString("Playback"));
g_pMainWindow->m_pPlayback->SetPlaybackInitialized(true);
return 1;
}
void HistoricalInfo::HistoricData_Read(QTextStream & reader)
{
QString line;
while (!(line = reader.readLine()).isNull())
{
if (line.isEmpty())
continue; //skip the next if, go to while
if(line == "*")
{
break;
}
if(!Extractinfo(line, recSpeed))
printf("error occured while extracting historical data\n");
}
LoadHistoricalinfo(); //load segement data into a list
}
void QPlayback:: signalPlay()
{
g_pMainWindow->m_pHist->HistoricData_Read(g_pMainWindow->m_pHist->reader); ///**************
ptrModelV->paintEvent(e); //refresh map
printf("PAINTING \n");
}
To copy to clipboard, switch view to plain text mode
***************this is where I get the segmentation fault. Is there anything obviously wrong with the code ?
Bookmarks