Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(595)

Unified Diff: ui/gl/gl_surface_ozone.cc

Issue 1865603002: ozone: Don't take a self reference in surfaceless adapter dtor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: be extra paranoid about IsCurrent() Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_surface_ozone.cc
diff --git a/ui/gl/gl_surface_ozone.cc b/ui/gl/gl_surface_ozone.cc
index 4815405d210b126b329919f5d8fc843966e9c3e1..da80397654374248b9305f0701a7c0ba0de7eaa5 100644
--- a/ui/gl/gl_surface_ozone.cc
+++ b/ui/gl/gl_surface_ozone.cc
@@ -578,8 +578,16 @@ void GLSurfaceOzoneSurfacelessSurfaceImpl::Destroy() {
if (!context_)
return;
scoped_refptr<gfx::GLContext> previous_context = gfx::GLContext::GetCurrent();
- scoped_refptr<gfx::GLSurface> previous_surface = gfx::GLSurface::GetCurrent();
- context_->MakeCurrent(this);
+ scoped_refptr<gfx::GLSurface> previous_surface;
+
+ bool was_current = previous_context && previous_context->IsCurrent(nullptr) &&
+ gfx::GLSurface::GetCurrent() == this;
+ if (!was_current) {
+ // Only take a reference to previous surface if it's not |this|
+ // because otherwise we can take a self reference from our own dtor.
+ previous_surface = gfx::GLSurface::GetCurrent();
+ context_->MakeCurrent(this);
+ }
glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
if (fbo_) {
@@ -594,7 +602,7 @@ void GLSurfaceOzoneSurfacelessSurfaceImpl::Destroy() {
image->Destroy(true);
}
- if (previous_context.get()) {
+ if (!was_current) {
previous_context->MakeCurrent(previous_surface.get());
} else {
context_->ReleaseCurrent(this);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698