Code review comment for lp:~verzegnassi-stefano/ubuntu-docviewer-app/lok-qml-async-imageprovider

By doing so, the app crashes any time a document is loaded.

It does not crash always at the same point, but it may occur at two different points:

1) In the internalRenderCallback, when it calls "doNextTask()", it crashes at line 84 of the renderengine.cpp

    if (m_activeTaskCount && !task->canBeRunInParallel(m_lastTask))
        return;

2) In lopartsimageresponse.cpp, when deleting m_task. (No other info is visible on the debugger)

void LOPartsImageResponse::cancel()
{
    disconnect(RenderEngine::instance(), &RenderEngine::taskRenderFinished,
               this, &LOPartsImageResponse::slotTaskRenderFinished);

    if (m_task) {
        QMetaObject::invokeMethod(RenderEngine::instance(), "dequeueTask",
                                  Qt::QueuedConnection,
                                  Q_ARG(int, m_task->id()));

        delete m_task;
    }
}

With the current code, I really think we should give the ownership of the task to the RenderEngine.

As we discussed earlier, the code I wrote is not so good because the ImageResponse gets the ownership and then it gives that ownership away in a asymmetrical/strange/ugly way.

Supposed that we should try to make RenderEngine work properly with different threads, could we revert to the code I wrote earlier (RenderEngine takes ownership of the tasks, and we connect to it using a BlockingQueueConnection)?
It used to work with no issue when we tried it.

« Back to merge proposal