Please describe what the "I/O Possible" SIGIO error typically indicates, from a QT C++ prospective. I know I/O stands for Input/output, but that's about all I know. The only decent information I have found is: http://davmac.org/davpage/linux/async-io.html but it is too generic to help me with my problem.
I don't necessarily need an answer telling me exactly what I did wrong (below), but hope to get a more informative answer on what activities generally lead to this error and what it indicates your doing wrong.
The remaining section will give you an idea on the activities I am doing, but your answer need to be specific to this section (my code) at all and can just describe what the error indicates and any specific QT information related to it
I am receiving this error sometimes on first loop and other times after 5 loops or so. It crashes the gui. This takes place in qt 4.8 on linux. A similar section of code is below which takes place on a QThread from my main gui.
Test.h
QBuffer *qbuff;
QByteArray qbyte;
Test.cpp
void Test::callExample()
{
for (int i=0;i<10;i++)
{
wait(1);
example();
}
}
void Test::example()
{
QFile inFile("/public/sounds/test.wav");
inFile.open(QIODevice::ReadOnly);
QByteArray qbyte = inFile.readAll();
inFile.close();
qbuff=new QBuffer();
qbuff->setData(qbyte);
qbuff->open(QIODevice::ReadOnly);
qbuff->seek(0);
audioOutput->start(qbuff);
}
In my full code, in example() I also have an event loop which, when finished, delete's qbuff and audioOutput. The error seems to come from various code locations, most often after an event change to idleState from event loop, but the actual problem should originate from the code shown. I have also tried moving the loop in callExample() to inside my eventloop, and even from my main thread (thus creating a new thread each call) but I still get the issue. I don't seem to get the error if there is no loop and the function is only called once or if the code takes place in my main gui rather than qthread.
Problem is a lifetime of your
QByteArray qbyte;
. It should be more or equal of lifetime ofQBuffer *qbuff;
. When you exit yourexample
method,qbyte
buffer is not exists anymore and your*qbuff
became corrupted (points on non-existing object).Possible, you want to write
qbyte = inFile.readAll();
instead of declaring local variable?