Results 1 to 4 of 4

Thread: segmentation fault

  1. #1

    Default segmentation fault

    I keep getting segmentation fault and file not opened error ? Can anyone help ?


    Qt Code:
    1. int HistoricalInfo::Load(const QString & strFilename)
    2. {
    3. QFile file(strFilename); //IODevice
    4.  
    5. reader.setDevice(&file);
    6.  
    7. h_strFilename = strFilename; //save the file name
    8.  
    9. if (!file.open(IO_ReadOnly | IO_Translate))
    10. {
    11. errno = ENOENT;
    12. return 0;
    13. }
    14. else
    15. {
    16. printf("File opened successfully \n");
    17. }
    18. if (g_pMainWindow != NULL && g_pMainWindow->m_pLblStatus != NULL)
    19. g_pMainWindow->m_pLblStatus->setText("Loading Historical Info...");
    20.  
    21. g_pMainWindow->m_pPlayback = new QPlayback(g_pMainWindow->tabsContainer, "playback");
    22.  
    23. g_pMainWindow->tabsWidget->addTab(g_pMainWindow->m_pPlayback, QString("Playback"));
    24.  
    25. g_pMainWindow->m_pPlayback->SetPlaybackInitialized(true);
    26.  
    27. return 1;
    28. }
    29.  
    30. void HistoricalInfo::HistoricData_Read(QTextStream & reader)
    31. {
    32. QString line;
    33.  
    34. while (!(line = reader.readLine()).isNull())
    35. {
    36. if (line.isEmpty())
    37. continue; //skip the next if, go to while
    38. if(line == "*")
    39. {
    40. break;
    41. }
    42. if(!Extractinfo(line, recSpeed))
    43. printf("error occured while extracting historical data\n");
    44. }
    45.  
    46. LoadHistoricalinfo(); //load segement data into a list
    47.  
    48. }
    49.  
    50. void QPlayback:: signalPlay()
    51. {
    52.  
    53. g_pMainWindow->m_pHist->HistoricData_Read(g_pMainWindow->m_pHist->reader); ///**************
    54. ptrModelV->paintEvent(e); //refresh map
    55. printf("PAINTING \n");
    56. }
    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 ?
    Last edited by jpn; 30th July 2008 at 08:18. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: segmentation fault

    Don't invoke paintEvent() directly. Use QWidget::update() (or repaint() if you really have to).

    Could you post the backtrace?

  3. #3

    Default Re: segmentation fault

    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?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: segmentation fault

    Quote Originally Posted by uchennaanyanwu View Post
    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?

Similar Threads

  1. QTreeWidgetItem - segmentation fault
    By szczav in forum Qt Programming
    Replies: 1
    Last Post: 4th June 2007, 22:54
  2. Process aborted. Segmentation fault
    By Pragya in forum Qt Programming
    Replies: 3
    Last Post: 30th May 2007, 08:12
  3. Replies: 2
    Last Post: 19th May 2007, 18:25
  4. Segmentation fault running any QT4 executables
    By jellis in forum Installation and Deployment
    Replies: 7
    Last Post: 19th May 2007, 16:35
  5. Icons missing => segmentation fault
    By antonio.r.tome in forum Qt Programming
    Replies: 4
    Last Post: 8th March 2006, 16:30

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.