View Single Post
Community Council | Posts: 680 | Thanked: 1,227 times | Joined on Sep 2010 @ Mbabane
#4409
Originally Posted by NerdKnight View Post
Hi Scorpius, I think I found the problem causing Yappari to consume too much CPU, the problem is located here:
Code:
void BinTreeNodeReader::fillArray(QByteArray& buffer, quint32 len)
{
Utilities::logData("Debug: BinTreeNodeReader::fillArray");
    char data[1025];

    buffer.clear();

    // bool ready = true;

    /*
    if (socket->bytesAvailable() < 1)
    {
        Utilities::logData("fillArray() waiting for bytes");
        ready = socket->waitForReadyRead(READ_TIMEOUT);
    }

    if (!ready)
    {
        Utilities::logData("fillArray() not ready / timed out");
        throw IOException(socket->error());
    }
    */

    int needToRead = len;
    while (needToRead > 0)
    {
        Utilities::logData("Debug: BinTreeNodeReader::fillArray--loop");
        int bytesRead = socket->read(data,(needToRead > 1024) ? 1024 : needToRead);

        if (bytesRead < 0)
            throw IOException(socket->error());
        if (bytesRead == 0)
            // socket->waitForReadyRead(READ_TIMEOUT);
            qApp->processEvents();
        else
        {
            needToRead -= bytesRead;
            buffer.append(data,bytesRead);
        }
    }
}
Maybe I missed something, where did you get this code?