Skip to content

Commit

Permalink
Fix GlContext (attachments) cleanup in case of a failing GlContext in…
Browse files Browse the repository at this point in the history
…itialization.

PiperOrigin-RevId: 600974501
  • Loading branch information
MediaPipe Team authored and copybara-github committed Jan 24, 2024
1 parent b76b7e2 commit 1033f56
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions mediapipe/gpu/gl_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -409,17 +409,15 @@ GlContext::~GlContext() {
if (thread_->IsCurrentThread()) {
thread_.release()->SelfDestruct();
}
} else {
if (IsCurrent()) {
} else if (IsCurrent()) {
clear_attachments();
} else if (HasContext()) {
ContextBinding saved_context;
auto status = SwitchContextAndRun([&clear_attachments] {
clear_attachments();
} else {
ContextBinding saved_context;
auto status = SwitchContextAndRun([&clear_attachments] {
clear_attachments();
return absl::OkStatus();
});
ABSL_LOG_IF(ERROR, !status.ok()) << status;
}
return absl::OkStatus();
});
ABSL_LOG_IF(ERROR, !status.ok()) << status;
}
DestroyContext();
}
Expand Down

0 comments on commit 1033f56

Please sign in to comment.