Skip to content

Commit

Permalink
#2467 proper resource cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Apr 5, 2024
1 parent 2422a48 commit ca3f0d5
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions xpra/client/gl/backing.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
GL_TEXTURE_MAX_LEVEL, GL_TEXTURE_BASE_LEVEL,
glActiveTexture, glTexSubImage2D,
glViewport,
glGenTextures, glDisable,
glGenTextures, glDeleteTextures,
glDisable,
glBindTexture, glPixelStorei, glFlush,
glBindBuffer, glGenBuffers, glBufferData, glDeleteBuffers,
glTexParameteri,
Expand All @@ -47,7 +48,7 @@
from OpenGL.GL.ARB.framebuffer_object import (
GL_FRAMEBUFFER, GL_DRAW_FRAMEBUFFER, GL_READ_FRAMEBUFFER,
GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1,
glGenFramebuffers, glBindFramebuffer, glFramebufferTexture2D, glBlitFramebuffer,
glGenFramebuffers, glDeleteFramebuffers, glBindFramebuffer, glFramebufferTexture2D, glBlitFramebuffer,
)

from xpra.os_util import POSIX, OSX, gi_import
Expand Down Expand Up @@ -542,14 +543,6 @@ def close(self) -> None:

def close_gl(self, context):
self.free_cuda_context()
# This seems to cause problems, so we rely
# on destroying the context to clear textures and fbos...
# if self.offscreen_fbo is not None:
# glDeleteFramebuffers(1, [self.offscreen_fbo])
# self.offscreen_fbo = None
# if self.textures is not None:
# glDeleteTextures(self.textures)
# self.textures = None
try:
from OpenGL.GL import glDeleteProgram, glDeleteShader
glBindVertexArray(0)
Expand All @@ -576,6 +569,14 @@ def close_gl(self, context):
if vao:
self.vao = None
glDeleteVertexArrays(1, [vao])
ofbo = self.offscreen_fbo
if ofbo is not None:
self.offscreen_fbo = None
glDeleteFramebuffers(1, [ofbo])
textures = self.textures
if textures is not None:
self.textures = None
glDeleteTextures(textures)
except Exception as e:
log(f"{self}.close()", exc_info=True)
log.error("Error closing OpenGL backing, some resources have not been freed")
Expand Down

0 comments on commit ca3f0d5

Please sign in to comment.