Skip to content

Draft: qt/qtitem: Fixed refcounting for borrowed wayland display

This is proposed solution for refcount issues with dynamically created and destroyed qtitem objects. If the solution is ok I will check the other platform code pathes and adjust them accordingly and also check for qt6 if the same solution is needed there.

The wayland display object we get Qt remains in Qt ownership. We must make sure that:

  1. We do not keep a reference to the object when QGuiApplication tears down the display.
  2. We do not disconnect the display while QGuiApplication still has it in use.

The current code will unref the wl display wrapper (GstGLDisplay) which in turn will flush and disconnect the wl_display once GstGLVideoItem goes out of scope. This will break any further rendering from Qt. This could happen if GstGLVideoItem has been instantiated within a QML Loader or dynamically created and destroyed from Javascript.

On the other hand we have to make sure that we do not keep a display object though the QGuiApplication is already gone.

This patch fixes this by keeping one reference to the display within gstqtglutility and only release this if Qt does no longer need the wl display connection, this is when QGuiApplication::aboutToQuit() signal is emitted.

Another reference is kept within each instance of GstGLVideoItem, these will be released if either the QML object tree is deleted or if the GstGLVideoItem is somehow destroyed before.

Merge request reports