From 8f43934be6303be00e8dccb00ed97b42bfd60600 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Sun, 17 Sep 2017 02:38:32 -0700 Subject: [PATCH] UI: Lock graphics context when adding new sources Prevents a potential cross-lock deadlock. The UI thread would lock the scene's mutex in obs_scene_atomic_update, then the item would lock the graphics context to create a texture. Meanwhile in the video thread, it could lock the graphics context in the render loop, then lock the scene's mutex when rendering. When doing anything graphics-related, the graphics context is always supposed to be locked before the scene's mutex is supposed to be locked (it's designed that way), and the obs_scene_atomic_update would just bypass that. --- UI/window-basic-source-select.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/UI/window-basic-source-select.cpp b/UI/window-basic-source-select.cpp index 4cb6f09e1..72b355806 100644 --- a/UI/window-basic-source-select.cpp +++ b/UI/window-basic-source-select.cpp @@ -137,7 +137,10 @@ static void AddExisting(const char *name, bool visible, bool duplicate) AddSourceData data; data.source = source; data.visible = visible; + + obs_enter_graphics(); obs_scene_atomic_update(scene, AddSource, &data); + obs_leave_graphics(); obs_source_release(source); } @@ -165,7 +168,10 @@ bool AddNew(QWidget *parent, const char *id, const char *name, AddSourceData data; data.source = source; data.visible = visible; + + obs_enter_graphics(); obs_scene_atomic_update(scene, AddSource, &data); + obs_leave_graphics(); newSource = source;