Answer the question
In order to leave comments, you need to log in
When debugging, QtCreator doesn't stop at an error, how to debug then?
In debug mode, the application crashes with the following information:
ASSERT failure in QVector<T>::operator[]: "index out of range", file D:\Qt\Qt5.3.1_mingw\5.3\mingw482_32\include/QtCore/qvector.h, line 385
Invalid parameter passed to C runtime function.
template <typename T>
inline T &QVector<T>::operator[](int i)
{ Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::operator[]", "index out of range");
return data()[i]; }
#include <iostream>
#include <QApplication>
#include <QString>
void myMessageOutput(QtMsgType type, const QMessageLogContext & context, const QString & msg)
{
switch (type)
{
case QtDebugMsg:
std::cerr << QString("Debug: %1 (%2:%3, %4)\n").arg(msg).arg(context.file).arg(context.line).arg(context.function).toStdString();
break;
case QtWarningMsg:
std::cerr << QString("Warning: %1 (%2:%3, %4)\n").arg(msg).arg(context.file).arg(context.line).arg(context.function).toStdString();
break;
case QtCriticalMsg:
std::cerr << QString("Critical: %1 (%2:%3, %4)\n").arg(msg).arg(context.file).arg(context.line).arg(context.function).toStdString();
break;
case QtFatalMsg:
std::cerr << QString("Fatal: %1 (%2:%3, %4)\n").arg(msg).arg(context.file).arg(context.line).arg(context.function).toStdString();
abort();
}
}
int main(int argc, char *argv[])
{
qInstallMessageHandler(myMessageOutput);
QApplication a(argc, argv);
return a.exec();
}
Answer the question
In order to leave comments, you need to log in
He shouldn't. Put a breakpoint where you need it and it will stop there.
asserts are needed in order to inform the developer that he screwed up. Internally, assert calls abort() which unconditionally aborts program execution.
> "index out of range"
He wrote everything. The assert is called inside the vector. Where should he stay? In a vector? Set breakpoints and see what happens. Screw gdb qt-project.org/doc/qtcreator-2.6/creator-debugger-...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question