mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-04-10 09:38:48 -04:00
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:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user