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.
This commit is contained in:
jp9000
2017-09-17 02:38:32 -07:00
parent 2386bd6556
commit 8f43934be6

View File

@@ -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;