Skip to content

Commit d252aee

Browse files
committed
Make OnDraw a bit safer to avoid crashing on exiting OBS
1 parent 0e4c9e8 commit d252aee

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

obs-browser/browser-source-listener-base.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,20 @@ void BrowserSource::Impl::Listener::OnDraw( BrowserSurfaceHandle surfaceHandle,
2727
UNUSED_PARAMETER(height);
2828

2929
if (textureSet.count(surfaceHandle) > 0) {
30-
3130
obs_enter_graphics();
32-
if (browserSource->GetParent()->TryLockTexture()) {
33-
if (popupSurface != nullptr)
34-
gs_copy_texture_region(surfaceHandle, popupX, popupY, popupSurface, 0, 0, gs_texture_get_width(popupSurface), gs_texture_get_height(popupSurface));
35-
browserSource->SetActiveTexture(surfaceHandle);
36-
browserSource->GetParent()->UnlockTexture();
31+
if (browserSource)
32+
{
33+
if (browserSource->GetParent())
34+
{
35+
if (browserSource->GetParent()->TryLockTexture()) {
36+
if (popupSurface != nullptr)
37+
gs_copy_texture_region(surfaceHandle, popupX, popupY, popupSurface, 0, 0, gs_texture_get_width(popupSurface), gs_texture_get_height(popupSurface));
38+
browserSource->SetActiveTexture(surfaceHandle);
39+
browserSource->GetParent()->UnlockTexture();
40+
}
41+
}
3742
}
3843
obs_leave_graphics();
39-
4044
}
4145
else {
4246
blog(LOG_ERROR, "Asked to draw unknown surface with handle"

0 commit comments

Comments
 (0)