PDA

View Full Version : Runtime error after adding any type of variable or object to header file



Henrich
27th May 2015, 12:15
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>::operator[]: "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...
11180

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?


#ifndef RADARWINDOW_H
#define RADARWINDOW_H

#include <QMainWindow>
#include <QWidget>
#include <QObject>
#include <QtCore>
#include <QtGui>
#include <QTimer>
#include <QTime>
#include <QPen>
#include <QSound>

#include "mytextitem.h"
#include "cflwidget.h"

namespace Ui {
class RadarWindow;
}

class RadarWindow : public QMainWindow
{
Q_OBJECT

public:
explicit RadarWindow(QWidget *parent = 0);
~RadarWindow();

QVector<double> loadLatFromMap(const QString &filename);
QVector<double> loadLonFromMap(const QString &filename);
QStringList loadNavPoints(const QString &filename);
void drawMap(const QString &filename);
void drawMapSection(const QString &filename);
void drawNavPoints(const QStringList &navPointList, const double &scale);
void drawRWY(const QString &filename);
void drawCTR(const QString &filename);
void drawTMA(const QString &filename);
void drawAircraft(const QHash<QString, QStringList> &flightsimhash, const double &scale);
QVector<double> prediction_calculation(const double &init_LON, const double &init_LAT, const double &init_HDG, const double &seconds, const double &GS);
double BCOtoDEC(const double &code);
void drawCollisonPoint(const QString &aircraft_1, const QString &aircraft_2);
double calculateDistance(const double &LAT_1, const double &LON_1, const double &LAT_2, const double &LON_2);
void drawSTCAPoint(const QString &aircraft_1, const QString &aircraft_2);
bool determineSTCAPoint(const QString &aircraft_1, const QString &aircraft_2);
void testSTCA();
double getAlpha(const double &HDG);
double ROCD(const QHash<QString, QStringList> &flightsimhash, const QString CallSign);
QStringList readSTRIP(const QString &fileName, const QString &CallSign);
void overwriteSQUAWK(const QString &fileName, const QString &CallSign, const QString &squawk);

private slots:
void update_drawing();
void dataFromFlightSim(const QString &callSign, const QString &message);
void update_flightHistoryNum(const int &number);
void changeselection();
void aircraftClicked(const QString &text);
void deselectAircraft_slot(const QString &text);
void getSTRIPDataFrom(const QString &dataFrom);
void GSclicked_slot();
void CFLclicked_slot(const QString &callsign);

signals:
void changeEmergencyStatus(const bool &);
void closed_connection(const QString &callsign);
void CFLclicked(const QString &callsign);

private:
Ui::RadarWindow *ui;

QGraphicsScene *scene;
MyTextItem *mytextitem;
CFLWidget *cflwidget;

QGraphicsEllipseItem *ellipse;
QGraphicsRectItem *rectangle;
QPolygonF polygon;
QPolygonF poly;
QGraphicsLineItem *line;
QGraphicsPolygonItem *polygonItem;
QGraphicsTextItem *pointText;
QGraphicsTextItem *aircraftText;

QPainterPath *path;

QStringList CallSignList;
QStringList MessageList;
QStringList SelectedAircraftList;

QHash<QString, QStringList> FlightSimHash;

QStringList selectedCallSign;

QTimer *update_timer;
int FlightHistory_num;

int FROM;
int TO;

bool visibility;
bool HOMEpressed;

QStringList OnlineAircraftList;
QHash<QString, bool> STCAhash;
QString StripDataFrom;

protected:
//virtual void wheelEvent(QWheelEvent *event);
virtual void keyPressEvent(QKeyEvent *e);
virtual void keyReleaseEvent(QKeyEvent *e);
};

#endif // RADARWINDOW_H

anda_skoa
27th May 2015, 13:20
What does your runtime out of bounds access have to do with your header?

Find the QVector access that is causing the exit.

Cheers,
_

Henrich
29th May 2015, 10:54
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.

anda_skoa
29th May 2015, 12:07
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,
_

Henrich
29th May 2015, 18:27
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.