[vlc-commits] [Git][videolan/vlc][master] qt: connect signals when component is complete in VideoSurface

Steve Lhomme (@robUx4) gitlab at videolan.org
Thu May 16 14:24:50 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
10cee756 by Fatih Uzunoglu at 2024-05-16T13:56:43+00:00
qt: connect signals when component is complete in VideoSurface

Only after `QQuickItem::componentComplete()` is called, we
are sure that all bindings are assigned. Currently,
the signal handlers connected in construction depend
on other bindings.

This is not ideal, because there is no guarantee on the
binding evaluation ordering.

- - - - -


2 changed files:

- modules/gui/qt/maininterface/videosurface.cpp
- modules/gui/qt/maininterface/videosurface.hpp


Changes:

=====================================
modules/gui/qt/maininterface/videosurface.cpp
=====================================
@@ -210,12 +210,6 @@ VideoSurface::VideoSurface(QQuickItem* parent)
     setAcceptedMouseButtons(Qt::AllButtons);
     setFlag(ItemAcceptsInputMethod, true);
     setFlag(ItemHasContents, true);
-
-    connect(this, &QQuickItem::xChanged, this, &VideoSurface::onSurfacePositionChanged);
-    connect(this, &QQuickItem::yChanged, this, &VideoSurface::onSurfacePositionChanged);
-    connect(this, &QQuickItem::widthChanged, this, &VideoSurface::onSurfaceSizeChanged);
-    connect(this, &QQuickItem::heightChanged, this, &VideoSurface::onSurfaceSizeChanged);
-    connect(this, &VideoSurface::enabledChanged, this, &VideoSurface::updatePositionAndSize);
 }
 
 MainCtx* VideoSurface::getCtx()
@@ -365,6 +359,19 @@ QSGNode*VideoSurface::updatePaintNode(QSGNode* oldNode, QQuickItem::UpdatePaintN
     return node;
 }
 
+void VideoSurface::componentComplete()
+{
+    ViewBlockingRectangle::componentComplete();
+
+    connect(this, &QQuickItem::xChanged, this, &VideoSurface::onSurfacePositionChanged);
+    connect(this, &QQuickItem::yChanged, this, &VideoSurface::onSurfacePositionChanged);
+    connect(this, &QQuickItem::widthChanged, this, &VideoSurface::onSurfaceSizeChanged);
+    connect(this, &QQuickItem::heightChanged, this, &VideoSurface::onSurfaceSizeChanged);
+    connect(this, &VideoSurface::enabledChanged, this, &VideoSurface::updatePositionAndSize);
+
+    updatePositionAndSize();
+}
+
 void VideoSurface::onProviderVideoChanged(bool hasVideo)
 {
     if (!hasVideo)


=====================================
modules/gui/qt/maininterface/videosurface.hpp
=====================================
@@ -128,6 +128,8 @@ protected:
 
     QSGNode* updatePaintNode(QSGNode *, QQuickItem::UpdatePaintNodeData *) override;
 
+    void componentComplete() override;
+
 signals:
     void ctxChanged(MainCtx*);
     void surfaceSizeChanged(QSizeF);



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/10cee7560668590a59715d0b1bd769350e713a9d

-- 
This project does not include diff previews in email notifications.
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/10cee7560668590a59715d0b1bd769350e713a9d
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