[vlc-commits] [Git][videolan/vlc][master] qt: do not allow attaching multiple video surfaces to the provider

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Oct 3 08:32:24 UTC 2025



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
383aca8e by Fatih Uzunoglu at 2025-10-03T08:15:54+00:00
qt: do not allow attaching multiple video surfaces to the provider

Having multiple video surfaces is technically not possible,
but during scene transitions there can be multiple coexisting
video surface items in the scene.

For example, when switching to the player page, a new video
surface item is created before the old one (pip player) is
destroyed.

This patch makes the video surface item cooperative, that is,
it probes the existing video surface and detaches it first
before attaching itself to the provider. The last one created
becomes the active video surface.

- - - - -


2 changed files:

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


Changes:

=====================================
modules/gui/qt/maininterface/videosurface.cpp
=====================================
@@ -330,12 +330,18 @@ void VideoSurface::setVideoSurfaceProvider(VideoSurfaceProvider *newVideoSurface
         disconnect(this, nullptr, m_provider, nullptr);
         disconnect(&m_wheelEventConverter, nullptr, m_provider, nullptr);
         disconnect(m_provider, nullptr, this, nullptr);
+
+        assert(m_provider->videoSurface() == this);
+        m_provider->setVideoSurface({});
     }
 
     m_provider = newVideoSurfaceProvider;
 
     if (m_provider)
     {
+        if (const auto current = m_provider->videoSurface())
+            current->setVideoSurfaceProvider(nullptr); // it is probably not a good idea to break the QML binding here
+
         connect(this, &VideoSurface::mouseMoved, m_provider, &VideoSurfaceProvider::onMouseMoved);
         connect(this, &VideoSurface::mousePressed, m_provider, &VideoSurfaceProvider::onMousePressed);
         connect(this, &VideoSurface::mouseDblClicked, m_provider, &VideoSurfaceProvider::onMouseDoubleClick);
@@ -358,6 +364,9 @@ void VideoSurface::setVideoSurfaceProvider(VideoSurfaceProvider *newVideoSurface
 
         connect(&m_wheelEventConverter, &WheelToVLCConverter::vlcWheelKey, m_provider, &VideoSurfaceProvider::onMouseWheeled);
 
+        assert(!m_provider->videoSurface());
+        m_provider->setVideoSurface(this);
+
         setFlag(ItemHasContents, true);
         update(); // this should not be necessary right after setting `ItemHasContents`, but just in case
     }


=====================================
modules/gui/qt/maininterface/videosurface.hpp
=====================================
@@ -34,10 +34,14 @@ extern "C" {
 Q_MOC_INCLUDE( "maininterface/mainctx.hpp")
 
 class MainCtx;
+class VideoSurface;
 
 class VideoSurfaceProvider : public QObject
 {
     Q_OBJECT
+
+    QPointer<VideoSurface> m_videoSurface;
+
 public:
     VideoSurfaceProvider(bool threadedSurfaceUpdates = false, QObject* parent = nullptr);
     virtual ~VideoSurfaceProvider() {}
@@ -49,6 +53,9 @@ public:
     void setVideoEmbed(bool embed);
     bool hasVideoEmbed() const;
 
+    QPointer<VideoSurface> videoSurface() { return m_videoSurface; }
+    void setVideoSurface(QPointer<VideoSurface> videoSurface) { m_videoSurface = videoSurface; }
+
     bool supportsThreadedSurfaceUpdates() const { return m_threadedSurfaceUpdates; };
 
 signals:



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/383aca8e64e3ed25d939f98dbfc644d960f7ef1d

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/383aca8e64e3ed25d939f98dbfc644d960f7ef1d
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