[vlc-commits] [Git][videolan/vlc][master] 3 commits: qt: install event filter on render window at appropriate time in `CompositorX11UISurface`

Steve Lhomme (@robUx4) gitlab at videolan.org
Mon Apr 7 12:20:48 UTC 2025



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
0cbba659 by Fatih Uzunoglu at 2025-04-07T12:02:25+00:00
qt: install event filter on render window at appropriate time in `CompositorX11UISurface`

The event filter dereferences `m_uiWindow` (among other things) without checking if it is
a null pointer, so it should not be installed before `m_uiWindow` is a valid pointer.

- - - - -
703d8680 by Fatih Uzunoglu at 2025-04-07T12:02:25+00:00
qt: check if root item is null pointer in `CompositorX11UISurface::updateSizes()`

During initialization, `QVLCTools::restoreWindowPosition()` is called before the
window is shown (intentionally, as we don't want to resize after showing the
window). This is done before the content is set, which makes root item point to
a valid location.

Unlike what its name suggests, `QVLCTools::restoreWindowPosition()` may adjust
the size of the window which in turn may cause a resize event be generated, and
this event may be sent immediately (synchronous) and not deferred until going
back to the event loop.

In this case `updateSizes()` may be called, which is normally expected to be
called when everything is ready (i.e., root item, and its window are valid
pointers).

We can simply check if the root item pointer is null in `updateSizes()`,
and not dereference it if it is a null pointer. This should be safe because
when the root item is set, its size is set anyway.

We don't need to check for `m_uiWindow`, because it is set during construction.

- - - - -
f74194ff by Fatih Uzunoglu at 2025-04-07T12:02:25+00:00
qt: do not call `updateSizes()` and update root item size explicitly in `CompositorX11UISurface::setContent()`

When the content is set, there is no reason to call `updateSizes()`, because it updates
the sizes of multiple things, where in this case we only want to set the initial size of
the root item.

- - - - -


1 changed file:

- modules/gui/qt/maininterface/compositor_x11_uisurface.cpp


Changes:

=====================================
modules/gui/qt/maininterface/compositor_x11_uisurface.cpp
=====================================
@@ -74,8 +74,6 @@ CompositorX11UISurface::CompositorX11UISurface(QWindow* window, QScreen* screen)
         m_backingStorePainter->setCompositionMode(QPainter::CompositionMode_Source);
     }
 
-    m_renderWindow->installEventFilter(this);
-
     m_uiRenderControl = new CompositorX11RenderControl(window);
 
     m_uiWindow = new CompositorOffscreenWindow(m_uiRenderControl);
@@ -87,6 +85,8 @@ CompositorX11UISurface::CompositorX11UISurface(QWindow* window, QScreen* screen)
     if (!m_qmlEngine->incubationController())
         m_qmlEngine->setIncubationController(m_uiWindow->incubationController());
 
+    m_renderWindow->installEventFilter(this);
+
     if (m_context)
     {
         connect(m_uiWindow, &QQuickWindow::sceneGraphInitialized, this, [this]() {
@@ -151,11 +151,12 @@ CompositorX11UISurface::~CompositorX11UISurface()
 
 void CompositorX11UISurface::setContent(QQmlComponent*,  QQuickItem* rootItem)
 {
+    assert(rootItem);
     m_rootItem = rootItem;
 
     m_rootItem->setParentItem(m_uiWindow->contentItem());
 
-    updateSizes();
+    m_rootItem->setSize(size());
 
     m_rootItem->forceActiveFocus();
 
@@ -270,6 +271,8 @@ bool CompositorX11UISurface::render()
 
 void CompositorX11UISurface::updateSizes()
 {
+    assert(m_uiWindow);
+
     qreal dpr = devicePixelRatio();
     QSize windowSize = size();
 
@@ -279,7 +282,8 @@ void CompositorX11UISurface::updateSizes()
         m_backingStore->resize(m_onscreenSize);
 
     // Behave like SizeRootObjectToView.
-    m_rootItem->setSize(windowSize);
+    if (m_rootItem)
+        m_rootItem->setSize(windowSize);
     m_uiWindow->resize(windowSize);
 }
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/95a8efe43af7ac5ab6ba061f662ecd8acd45f3b6...f74194ffd858608ba944e1584b6d2e9aa610ff6a

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/95a8efe43af7ac5ab6ba061f662ecd8acd45f3b6...f74194ffd858608ba944e1584b6d2e9aa610ff6a
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list