Strange behavior of program on Qt 5

72 views Asked by At

I'm writing two programs on Qt 5. The first ("Debug") program sends requests to the second ("Simulator") through a PCI-E device. The "Simulator" must respond as fast as possible. This is a separate issue, but now I want to ask about another strange effect. The "Debug" program writes 10 bytes from QLineEdit to a PCI-E device and then waits for an answer from the "Simulator". When the answer came fast enough, I see the right data bytes in the "Debug" program window, otherwise a PCI-E device returns a copy of a sended data and I see it too. The issue is that data can be sended by two ways: by clicking the Send button on the form and by clicking the Return button on a keyboard. In both cases the data is sent from the following slot:

void MyWin::on_pushButton_Send_clicked()
{
    if(data_matched)
    {
        QString exp = ui.lineEdit_Data->text();

        QStringList list = exp.split(QRegExp("\\s"), 
            QString::SkipEmptyParts);

        for(int i=0; i<list.size(); i++)
        {
            quint8 a = list[i].toUInt(0, 16);
            data[i] = a;
        }

        write_insys(bHandle, data, DataSize);

        ui.textEdit->append( /* show sended bytes */ );       

        read_insys(bHandle, data, DataSize);

        ui.textEdit->append( /* show received bytes */ );
    }
}

But in the second case (on Return key press) the only difference is that the above slot is invoked inside the following:

void MyWin::on_lineEdit_Data_returnPressed()
{
    on_pushButton_Send_clicked();
}

But the results:

  • 1st case: 90% wrong answers
  • 2st case: 90% right answers

The code of write_insys and read_insys is absolutely trivial, simply call the library functions:

bool write_insys(BRD_Handle handle, void* data, int size)
{
    S32 res = BRD_putMsg(handle, NODE0, data, (U32*)&size, BRDtim_FOREVER);

    return (res >= 0);
}

bool read_insys(BRD_Handle handle, void* data, int size)
{
    S32 res = BRD_getMsg(handle, NODE0, data, (U32*)&size, BRDtim_FOREVER);

    return (res >= 0);
}

Does anyone know why this might happen?
Windows 7, Qt 5.4.2, Msvc 2010.

edit: Most likely it is a Qt bug...

0

There are 0 answers