[Interest] Setting QQuickItem properties inside QQuickItem::UpdatePaintNode

Gunnar Sletta gunnar.sletta at jolla.com
Thu Jun 5 07:13:50 CEST 2014


On 05 Jun 2014, at 06:45, manish sharma <83.manish at gmail.com> wrote:

> Hi,
> 
> Qt documentation says "The main thread is blocked while this function is executed so it is safe to read values from the QQuickItem instance and other objects in the main thread."
> 
> Can we only read QQuickItem properties? We can not set it?

You can, but anything tied to those properties will have their signals emitted on the render thread which may result in bad stuff. For instance, if something is bound to that property in QML the signal emission will be done using a queued connection so the binding will not be evaluated until later on the GUI thread. That effectively means you get incorrect anchors and positioners and similar. Not ideal. On the other hand, if you start timers, as a result of something tied to the setter or its notify signal, those timers will have affinity to the render thread and be fired there. That can result in pretty much anything.

So I would strongly discourage it :) If you need to delay something and do it "just before rendering", you should use QQuickItem::polish() and QQuickItem::updatePolish().

> I have few QQuickItems and I am trying to set QQuickItem properties (height/width) from one of the QQuickItem's updatePaintNode function. So far it worked but when I try QQuickWindow::grabWindow() it asserts both in windows (QML_FORCE_THREADED_RENDERER=1) and Linux.
> 
> ASSERT failure in QQuickItem::update(): "Function can only be called from GUI thread or during QQuickItem::updatePaintNode()", file E:\Qt\qt5.2\qt5\qtdeclarative\src\quick\scenegraph\qsgthreadedrenderloop.cpp, line 988
> 
> I noticed QSGThreadedRenderLoop::m_locked is false. Is it a bug in QSGThreadedRenderLoop OR we can not set QQuickItem properties inside updatePaintNode which might cause QQuickItem::update()?

It is a bug, does https://codereview.qt-project.org/86823 help?

cheers,
Gunnar

> 
> Regards,
> Manish
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest




More information about the Interest mailing list