Results 1 to 5 of 5

Thread: Runtime error after adding any type of variable or object to header file

  1. #1
    Join Date
    Sep 2013
    Location
    Bratislava, Slovakia
    Posts
    8
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Runtime error after adding any type of variable or object to header file

    Hi all,

    When I want to add almost anything to .h file like "double", "int" declaration or basicly anything, Qt throws an error: exited with code -1073741819 in Release mode. When I compile the code in Debug mode it throws an error:

    ASSERT failure in QVector<T>:perator[]: "index out of range", file c:\QtSDK\Desktop\Qt\4.8.1\mingw\include/QtCore/qvector.h, line 359
    Invalid parameter passed to C runtime function.
    Invalid parameter passed to C runtime function.

    In stack, the debugger complains that it cannot access memory at adress...
    debugg.png

    here is the code of my header file, if I comemnt out the "CFLWidget *cflwidget;" everything works fine, even I'm not using it anywhere else yet. The same happens when I just add any double for example. I don't understand what is going on in here...Can anyone help me somehow?

    Qt Code:
    1. #ifndef RADARWINDOW_H
    2. #define RADARWINDOW_H
    3.  
    4. #include <QMainWindow>
    5. #include <QWidget>
    6. #include <QObject>
    7. #include <QtCore>
    8. #include <QtGui>
    9. #include <QTimer>
    10. #include <QTime>
    11. #include <QPen>
    12. #include <QSound>
    13.  
    14. #include "mytextitem.h"
    15. #include "cflwidget.h"
    16.  
    17. namespace Ui {
    18. class RadarWindow;
    19. }
    20.  
    21. class RadarWindow : public QMainWindow
    22. {
    23. Q_OBJECT
    24.  
    25. public:
    26. explicit RadarWindow(QWidget *parent = 0);
    27. ~RadarWindow();
    28.  
    29. QVector<double> loadLatFromMap(const QString &filename);
    30. QVector<double> loadLonFromMap(const QString &filename);
    31. QStringList loadNavPoints(const QString &filename);
    32. void drawMap(const QString &filename);
    33. void drawMapSection(const QString &filename);
    34. void drawNavPoints(const QStringList &navPointList, const double &scale);
    35. void drawRWY(const QString &filename);
    36. void drawCTR(const QString &filename);
    37. void drawTMA(const QString &filename);
    38. void drawAircraft(const QHash<QString, QStringList> &flightsimhash, const double &scale);
    39. QVector<double> prediction_calculation(const double &init_LON, const double &init_LAT, const double &init_HDG, const double &seconds, const double &GS);
    40. double BCOtoDEC(const double &code);
    41. void drawCollisonPoint(const QString &aircraft_1, const QString &aircraft_2);
    42. double calculateDistance(const double &LAT_1, const double &LON_1, const double &LAT_2, const double &LON_2);
    43. void drawSTCAPoint(const QString &aircraft_1, const QString &aircraft_2);
    44. bool determineSTCAPoint(const QString &aircraft_1, const QString &aircraft_2);
    45. void testSTCA();
    46. double getAlpha(const double &HDG);
    47. double ROCD(const QHash<QString, QStringList> &flightsimhash, const QString CallSign);
    48. QStringList readSTRIP(const QString &fileName, const QString &CallSign);
    49. void overwriteSQUAWK(const QString &fileName, const QString &CallSign, const QString &squawk);
    50.  
    51. private slots:
    52. void update_drawing();
    53. void dataFromFlightSim(const QString &callSign, const QString &message);
    54. void update_flightHistoryNum(const int &number);
    55. void changeselection();
    56. void aircraftClicked(const QString &text);
    57. void deselectAircraft_slot(const QString &text);
    58. void getSTRIPDataFrom(const QString &dataFrom);
    59. void GSclicked_slot();
    60. void CFLclicked_slot(const QString &callsign);
    61.  
    62. signals:
    63. void changeEmergencyStatus(const bool &);
    64. void closed_connection(const QString &callsign);
    65. void CFLclicked(const QString &callsign);
    66.  
    67. private:
    68. Ui::RadarWindow *ui;
    69.  
    70. MyTextItem *mytextitem;
    71. CFLWidget *cflwidget;
    72.  
    73. QGraphicsRectItem *rectangle;
    74. QPolygonF polygon;
    75. QPolygonF poly;
    76. QGraphicsPolygonItem *polygonItem;
    77. QGraphicsTextItem *pointText;
    78. QGraphicsTextItem *aircraftText;
    79.  
    80. QPainterPath *path;
    81.  
    82. QStringList CallSignList;
    83. QStringList MessageList;
    84. QStringList SelectedAircraftList;
    85.  
    86. QHash<QString, QStringList> FlightSimHash;
    87.  
    88. QStringList selectedCallSign;
    89.  
    90. QTimer *update_timer;
    91. int FlightHistory_num;
    92.  
    93. int FROM;
    94. int TO;
    95.  
    96. bool visibility;
    97. bool HOMEpressed;
    98.  
    99. QStringList OnlineAircraftList;
    100. QHash<QString, bool> STCAhash;
    101. QString StripDataFrom;
    102.  
    103. protected:
    104. //virtual void wheelEvent(QWheelEvent *event);
    105. virtual void keyPressEvent(QKeyEvent *e);
    106. virtual void keyReleaseEvent(QKeyEvent *e);
    107. };
    108.  
    109. #endif // RADARWINDOW_H
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Runtime error after adding any type of variable or object to header file

    What does your runtime out of bounds access have to do with your header?

    Find the QVector access that is causing the exit.

    Cheers,
    _

  3. #3
    Join Date
    Sep 2013
    Location
    Bratislava, Slovakia
    Posts
    8
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Runtime error after adding any type of variable or object to header file

    The problem is, that there is no QVector that is causing this error. For example, when I add to that header another QString, it crashes, but when I add one more in works again. And none of those newly added I'm not using in source file. That is what is strange and I can't solve.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Runtime error after adding any type of variable or object to header file

    I see plenty of QVectors being used in your code snippet.

    The stack trace at the time of error should point to the access that goes wrong.

    In any case, have you done a clean rebuild?

    Cheers,
    _

  5. The following user says thank you to anda_skoa for this useful post:

    Henrich (29th May 2015)

  6. #5
    Join Date
    Sep 2013
    Location
    Bratislava, Slovakia
    Posts
    8
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Runtime error after adding any type of variable or object to header file

    Thank you for your advice.

    Yes, you are right, there are many QVectors, but none of them is causing the error.
    The stack trace shows only reference to the ntdll.dll, what is a windows library. I did "clean all" , run qmake and "rebuild all", but nothing changed.

    But just now it looks like I solved it. I deleted also Makefiles from my build directory, and rebuild it again, and it's working for now. Looks like when I wanted to add Q_OBJECT macro, something went wrong, and deleting everything related and rebuilding all solved that problem. Just don't understand why is this happening, and also the debugger and stack trace will not direct me to the source of the problem.

Similar Threads

  1. Replies: 0
    Last Post: 28th October 2014, 18:16
  2. Thread safe initialization of const variable in header file
    By kangaba in forum General Programming
    Replies: 1
    Last Post: 19th March 2014, 22:53
  3. Error in reading wav-file header
    By davidlamhauge in forum Qt Programming
    Replies: 5
    Last Post: 18th November 2012, 15:35
  4. Replies: 8
    Last Post: 29th July 2012, 02:28
  5. Replies: 1
    Last Post: 4th September 2008, 15:55

Tags for this Thread

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.