Hi I've got this code that generates some odd behaviour:

Qt Code:
  1. void function A(){
  2. QString Error = "";
  3. for (int i = 0; i < params.size(); i++){
  4. Error = function B();
  5. qDebug() << "Done B";
  6. }
  7. }
  8.  
  9.  
  10. QString function B(){
  11. //Very long cycle that does many things and calls many functions that might return erros
  12. qDebug() << "Returning B";
  13. return "";
  14. }
To copy to clipboard, switch view to plain text mode 

The program crashes and shows this result on the output:

.
.
.
Returning B
ASSERT failure in QVector<T>:perator[]: "index out of range", file c:/Qt/QtCreator/qt/include/QtCore/../../src/corelib/tools/qvector.h, line 325
Done B
.
.
.
.

Even after this error the program keeps on executing a while longer (seemingly correctly) before crashing with a Runtime Error with a dialog box from the Microsoft Visual C++ Runtime Library. (I'm using the full QtCreator instalation to write and compile my soft.).

My thinking is that this QVector error found at some other point in the program and it get written to the console at the point shown. So what I want to know is how I can know exactly in which vector did the error ocurr. I was thinking something along the a try-catch but I don't know how to use them with Qt. And it seems that it's not supported.

Thanks for anyhelp.