Application closed Unexpectedly when timer call start



  • Hi Friends

    I am facing a problem with Timer call. when start timer on 1sec timer interval my application mainwindow closed un expectedly. the compiler throws an error "The program has unexpectedly finished"

    Here is my Code:

    void Data_Acquisition_Form::Protocol_Data_split(QList<QByteArray> Data)
    {
        bool ok;
        //qDebug()<<"Demo  NOT clicked";
    
        if(!Demo_Clicked_MainW)
      {
       qDebug()<<"Demo NOt Clicked";
    
        for(int i = 0; i < (Data.size() - 1); i++)
        {
    
            QString Single_Frame = Data.value(i);
            //                qDebug() << Single_Frame;
            if((Single_Frame.mid(2,2)) == "66")
            {
                Single_Frame.insert(2, "0d");
            }
    
            if(((Single_Frame.mid(2,2)).toInt(&ok, 16) * 2) == Single_Frame.size())                  // To check the Data loss (Checking No.Of Bytes with Frame Size)
            {
                int x = 14;                                 // Exclude the 7 bytes data (Machine_Id, Bed_No)
    
                /************************************************************************************************************************/
    
                if((Single_Frame.mid(x,2)) == "5d")            // --------------- ] Status Byte Data
                {
                    QString Temp_data = ((Single_Frame.mid(x+2, 2))); // Extract the Data
                    qDebug()<<"Staus data RAW data"<<Temp_data;
                    int Temp_data_int = Temp_data.toInt(&ok, 16);                                                   // Convert the Hexadecimal Data to Integer
                    QString Status_data_Binary = (Temp_data.setNum(Temp_data_int, 2)).rightJustified(16, '0');      // Convert the Integer Data to Binary and Make the Size stable to 16-Bits and Prepend zeroes(0)
                    qDebug()<<"Status Data Binary From RAW data:"<<Status_data_Binary;
                    emit SEND_STATUS_BYTE_DATA(Status_data_Binary);
                    //                qDebug() << Status_data_Binary_temp;
                    x += 6;
                }
                /************************************************************************************************************************/
    
                if((Single_Frame.mid(x,2)) == "26")            // ----------- & - SpO2, Pulse Rate Value
                {
                    emit SEND_SPO2_PR_DATA((Single_Frame.mid(x+2, 2).toInt(&ok, 16)), ((Single_Frame.mid(x+4, 2)).toInt(&ok, 16)));
                    x += 6;
                }
                /************************************************************************************************************************/
    
                if((Single_Frame.mid(x,2)) == "5b")            // --------------- [ NIBP (SYS, DIA, MEAN) Data
                {
                    emit SEND_NIBP_DATA(((Single_Frame.mid(x+2, 2)).toInt(&ok, 16)), ((Single_Frame.mid(x+4, 2)).toInt(&ok, 16)), ((Single_Frame.mid(x+6, 2)).toInt(&ok, 16)));
                    x += 8;
                }
                /************************************************************************************************************************/
    
                if((Single_Frame.mid(x,2)) == "2a")            // --------------- * NIBP Cuff Pressure Data
                {
                    emit SEND_NIBP_CUFF_PRESSURE_DATA((Single_Frame.mid(x+2, 2)).toInt(&ok, 16));
                    x += 4;
                }
                /************************************************************************************************************************/
    
                if((Single_Frame.mid(x,2)) == "3c")            // --------------- < NIBP ERROR Data
                {
                    x += 4;
                }
                /************************************************************************************************************************/
    
                if((Single_Frame.mid(x,2)) == "5e")            // --------------- ^ Heart Rate Data
                {
                    emit SEND_HEART_RATE_DATA((Single_Frame.mid(x+2, 4)).toInt(&ok, 16));
                    x += 6;
                }
                /************************************************************************************************************************/
    
                if((Single_Frame.mid(x,2)) == "29")            // --------------- ) ST Analysis Data
                {
                    //                emit SEND_ST_ANALYSIS_DATA(((Single_Frame.mid(x+2, 4)).toInt(&ok, 16)), ((Single_Frame.mid(x+6, 4)).toInt(&ok, 16)));
                    x += 10;
                }
                /************************************************************************************************************************/
    
                if((Single_Frame.mid(x,2)) == "7b")            // --------------- { PVC Data
                {
                    //                emit SEND_PVCs_DATA_TO_MAIN((Single_Frame.mid(x+2, 2)).toInt(&ok, 16));
                    x += 4;
                }
                /************************************************************************************************************************/
    
                if((Single_Frame.mid(x,2)) == "28")            // --------------- ( Respiration Rate Data
                {
                    emit(SEND_RESPIRATION_RATE_DATA((Single_Frame.mid(x+2, 2)).toInt(&ok, 16)));
                    x += 4;
                }
                /************************************************************************************************************************/
    
                if((Single_Frame.mid(x,2)) == "3b")            // --------------- ; Temp1, Temp 2 Data
                {
                    emit SEND_TEMP_DATA(((Single_Frame.mid(x+2, 4)).toInt(&ok, 16)), ((Single_Frame.mid(x+6, 4)).toInt(&ok, 16)));
                    x += 10;
                }
                /************************************************************************************************************************/
    
                if((Single_Frame.mid(x,2)) == "40")            // --------------- @ Fast Temperature Data
                {
                    emit SEND_FAST_TEMPERATURE_DATA((Single_Frame.mid(x+2, 4)).toInt(&ok, 16));
                    x += 6;
                }
                /************************************************************************************************************************/
    
                if((Single_Frame.mid(x,2)) == "21")         // ------------ ! - SpO2 Graph Data, Bar Graph Data
                {
                    emit SEND_SPO2_GRAPH_DATA(Single_Frame.mid(x+2, 2), Single_Frame.mid(x+4, 2));
                    //                emit SEND_SPO2_BAR_GRAPH_DATA(Single_Frame.mid(x+4, 2));
                    //                emit SEND_SPO2_BAR_GRAPH_DATA((Single_Frame.mid(x+4, 2)).toInt(&ok, 16));
                    x += 6;
                }
                /************************************************************************************************************************/
    
                if((Single_Frame.mid(x,2)) == "3d")            // --------------- = ECG Data
                {
                    if((Single_Frame.mid(x+18, 2)) == "2b")
                    {
                        emit SEND_ECG_LEADS_GRAPH_DATA((Single_Frame.mid(x+2, 4)), (Single_Frame.mid(x+6, 4)), (Single_Frame.mid(x+10, 4)), (Single_Frame.mid(x+14, 4)));
                    }
                    x += 18;
                }
    
                /************************************************************************************************************************/
    
                if((Single_Frame.mid(x,2)) == "2b")            // --------------- + Electrode Data
                {
                    emit SEND_ECG_ELECTRODE_GRAPH_DATA((Single_Frame).mid(x+2, 4), (Single_Frame).mid(x+6, 4));
                    x += 10;
                }
                /************************************************************************************************************************/
    
                if((Single_Frame.mid(x,2)) == "3e")            // --------------- > Respiration Graph Data
                {
                    emit SEND_RESPIRATION_GRAPH_DATA((Single_Frame).mid(x+2, 4), (Single_Frame).mid(x+6, 4));
                    x += 10;
                }
                /************************************************************************************************************************/
    
                if((Single_Frame.mid(x,2)) == "7e")            // --------------- > Arrhythmias Data
                {
                    //                emit SEND_ARR_DATA((Single_Frame).mid(x+2, 4));
                    x += 6;
                }
                /************************************************************************************************************************/
    
                if((Single_Frame.mid(x,2)) == "93" || (Single_Frame.mid(x,2)) == "22")            // --------------- > Dummy_Data "
                {
                    x += 4;
                }
                /************************************************************************************************************************/
    
                if((Single_Frame.mid(x,2)) == "60")            // --------------- > APNEA INDICATION `
                {
                    x += 4;
                }
                /************************************************************************************************************************/
    
                if((Single_Frame.mid(x,2)) == "e6")            // --------------- > Beep_Data
                {
                    //            qDebug() << "BEEP OCCURED";
                    //                emit SEND_BEEP_DATA((Single_Frame).mid(x+2, 2));
                    x += 4;
                }
                /************************************************************************************************************************/
            }
    
        }
      }
        else
        {
            qDebug()<<"Demo  clicked";
            DEMO_Mode_Timer_1->start();
    
         }
    }
    
    void Data_Acquisition_Form::DEMO_Mode_Timer_Initialization()
    {
        DEMO_Mode_Timer_1=new QTimer(this);
        DEMO_Mode_Timer_1->setInterval(1);
    
        connect(DEMO_Mode_Timer_1,SIGNAL(timeout()),this,SLOT(DEMO_Mode_Timer_Timeout()));
    }
    void Data_Acquisition_Form::DEMO_Mode_Timer_Timeout()
    {
        qDebug()<<"Demo timer Called +++++++++++";
    }
    

    when i uncomment this line from Protocol_Data_split() slot in else part the application works fine.

    DEMO_Mode_Timer_1->start();
    

    when i start the timer my application closed unexpectedly. I don't know what I am missing. Help need to resolve this issue.

    Thanks in Advance



  • @vivekyuvan hi,
    first off let me link you to this brief guide on what to do and not to do in using comments. First link, that poped up in a google dearch.

    Comments

    Because dear lord, your commentation makes your code hard to read, for me at least. No offense meant!

    To your problem, are you sure, you call DEMO_Mode_Timer_Initialization before Protocol_Data_split has a chance to be called?

    just to make sure, I would suggest the following code change:

    in your *h
    
    QTimer *DEMO_Mode_Timer_1 = Q_NULLPTR;
    
    
    //in your cpp file
    else{
            qDebug()<<"Demo  clicked";
            if(DEMO_Mode_Timer_1)
                 DEMO_Mode_Timer_1->start();
            else 
                 qDebug() << "Timer not initialized";
    }
    

  • Moderators

    @vivekyuvan said in Application closed Unexpectedly when timer call start:

    DEMO_Mode_Timer_1->start();

    This is actually easy to check: use debugger.
    Most probably DEMO_Mode_Timer_1 is null or invalid pointer. You can check using debugger. Did you try?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.