Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. problem with QASSERT_X

problem with QASSERT_X

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 1.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    riken7
    wrote on last edited by
    #1

    hello,
    I have a problem when I run my project on DEBUG mode.

    It ocurred the next error:
    C:\Users\ENRIQUE\build-TFGVF-Desktop_Qt_5_6_1_MSVC2015_64bit-Debug\debug\TFGVF.exe exited with code 3

    ASSERT failure in QList<T>::at: "index out of range", file C:\Qt\Qt5.6.1\5.6\msvc2015_64\include\QtCore/qlist.h, line 531

    template <typename T>
    inline const T &QList<T>::at(int i) const
    { Q_ASSERT_X(i >= 0 && i < p.size(), "QList<T>::at", "index out of range");
     return reinterpret_cast<Node *>(p.at(i))->t(); }
    

    I don't found the error in my project code, I think that the error is in this function:

    void MainWindow::listo_leer_serie(){
        info_arduino+=arduino_serie->readLine();
        //qDebug()<<info_arduino;
        if(info_arduino.contains("fin")){
            if(info_arduino.contains(",,,,,,,,,,")){
                info_arduino.replace(",,,,,,,,,,",",,,,,,,,,");
            }
            info_arduino.remove("fin");
            info_arduino=info_arduino.trimmed();
            QStringList lista_datos;
            lista_datos= info_arduino.split(",", QString::SkipEmptyParts);
            if(lista_datos.at(0)=="Datos"){
            if(lista_datos.size() == 12){
                qDebug()<<tr("Tenemos 12");
                QString help;
                for(int i=1; i<=7; i++){
                    help=lista_datos.at(i);
                    statesArduino[i] = help[0].toLatin1();
                    //qDebug()<<tr("Dato:%1").arg(QString::fromLatin1(statesArduino[i]));
                }
    
                help=lista_datos.at(8);
                powerR=help.toDouble();
                qDebug()<<tr("Potencia R:%1").arg(QString::number(powerR));
                help=lista_datos.at(9);
                powerS=help.toDouble();
                qDebug()<<tr("Potencia S:%1").arg(QString::number(powerS));
                help=lista_datos.at(10);
                powerT=help.toDouble();
                qDebug()<<tr("Potencia T:%1").arg(QString::number(powerT));
    
                help=lista_datos.at(11);
                irradiacionArduino = help.toDouble();
                qDebug()<<tr("Irradicion:%1").arg(QString::number(irradiacionArduino));
    
            }
            }
    //        if(info_arduino.contains("Todo")){
    //            dato1=info_arduino;
    //        }
    //        if(info_arduino.contains("va")){
    //            dato2=info_arduino;
    //        }
    //        if(info_arduino.contains("bien")){
    //            dato3=info_arduino;
    //        }
            //mensaje=dato1+"-"+dato2+"-"+dato3+"/n";
            mensaje=dato1;
            info_arduino="";
            //qDebug()<<tr("Lectura de datos realizada");
        }
        //ui->listWidget->addItem(dato1);
        //ui->listWidget->addItem(dato2);
        //ui->listWidget->addItem(dato3);
    
        //screenView();
        //screenLoads();
    
    }
    
    

    what coluld it be? I think that function is well but the erroralways ocurred when the code was running.

    thanks a lot

    I don't have much experience.
    I am sorry, my English is not good

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      before if(lista_datos.at(0)=="Datos") add a check for lista_datos being empty

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      2
      • R Offline
        R Offline
        riken7
        wrote on last edited by
        #3

        I don't understand you.

        do you refere that?:

        if(!lista_datos.at(0)->isEmpty()){
                if(lista_datos.at(0) =="Datos")
                        .....
        

        thnaks!

        mrjjM 1 Reply Last reply
        0
        • R riken7

          I don't understand you.

          do you refere that?:

          if(!lista_datos.at(0)->isEmpty()){
                  if(lista_datos.at(0) =="Datos")
                          .....
          

          thnaks!

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #4

          @riken7
          Hi i think more like

          if(!lista_datos.isEmpty()){
                  if(lista_datos.at(0) =="Datos")
                          .....
          

          as you will CRASH if you say at(0) and there is nothing in list.

          1 Reply Last reply
          3
          • R Offline
            R Offline
            riken7
            wrote on last edited by
            #5

            thanks everybody!!!
            I belive that problem is solved

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved