PDA

View Full Version : segmentation fault



uchennaanyanwu
30th July 2008, 02:30
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)
{
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");
}

***************this is where I get the segmentation fault. Is there anything obviously wrong with the code ?

jacek
30th July 2008, 23:11
Don't invoke paintEvent() directly. Use QWidget::update() (or repaint() if you really have to).

Could you post the backtrace?

uchennaanyanwu
31st July 2008, 01:00
I was able to fix my segmentation fault; however, I ran into other issues.

I cannot seem to get the widget to refresh/update. Instead of calling the paintEvent ( ), I called used QWidget::update ( ) . This doesn't seem to refresh my widget.

Please note that I am trying to update a mapvisual widget, declare as MapVisual, that displays a map on the screen using a button that I have created Play, which is declared in another another class QPlayback.

...Any ideas?

jacek
31st July 2008, 16:52
I cannot seem to get the widget to refresh/update. Instead of calling the paintEvent ( ), I called used QWidget::update ( ) . This doesn't seem to refresh my widget.
Do you have some kind of a loop in your application?