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:
parent
2386bd6556
commit
8f43934be6
1 changed files with 6 additions and 0 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue