mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-23 16:58:09 +02:00
Explicitly free sprites on normal program termination
This commit is contained in:
@@ -191,6 +191,7 @@ class Boss(Thread):
|
|||||||
# Must be called in the main thread as it manipulates signal handlers
|
# Must be called in the main thread as it manipulates signal handlers
|
||||||
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||||
signal.signal(signal.SIGTERM, signal.SIG_DFL)
|
signal.signal(signal.SIGTERM, signal.SIG_DFL)
|
||||||
|
self.char_grid.destroy()
|
||||||
|
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
self.shutting_down = True
|
self.shutting_down = True
|
||||||
|
|||||||
@@ -159,6 +159,9 @@ class CharGrid:
|
|||||||
viewport=Size(self.width, self.height), clear_color=self.original_bg,
|
viewport=Size(self.width, self.height), clear_color=self.original_bg,
|
||||||
cursor=self.default_cursor))
|
cursor=self.default_cursor))
|
||||||
|
|
||||||
|
def destroy(self):
|
||||||
|
self.sprites.destroy()
|
||||||
|
|
||||||
def initialize(self):
|
def initialize(self):
|
||||||
self.default_bg, self.default_fg = self.original_bg, self.original_fg
|
self.default_bg, self.default_fg = self.original_bg, self.original_fg
|
||||||
self.apply_opts(self.opts)
|
self.apply_opts(self.opts)
|
||||||
|
|||||||
@@ -487,6 +487,14 @@ DeleteTexture(PyObject UNUSED *self, PyObject *val) {
|
|||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject*
|
||||||
|
DeleteBuffer(PyObject UNUSED *self, PyObject *val) {
|
||||||
|
GLuint tex_id = (GLuint)PyLong_AsUnsignedLong(val);
|
||||||
|
glDeleteBuffers(1, &tex_id);
|
||||||
|
CHECK_ERROR;
|
||||||
|
Py_RETURN_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
BlendFunc(PyObject UNUSED *self, PyObject *args) {
|
BlendFunc(PyObject UNUSED *self, PyObject *args) {
|
||||||
int s, d;
|
int s, d;
|
||||||
@@ -559,6 +567,7 @@ int add_module_gl_constants(PyObject *module) {
|
|||||||
METH(ShaderSource, METH_VARARGS) \
|
METH(ShaderSource, METH_VARARGS) \
|
||||||
METH(CompileShader, METH_O) \
|
METH(CompileShader, METH_O) \
|
||||||
METH(DeleteTexture, METH_O) \
|
METH(DeleteTexture, METH_O) \
|
||||||
|
METH(DeleteBuffer, METH_O) \
|
||||||
METH(GetString, METH_O) \
|
METH(GetString, METH_O) \
|
||||||
METH(GetIntegerv, METH_O) \
|
METH(GetIntegerv, METH_O) \
|
||||||
METH(Clear, METH_O) \
|
METH(Clear, METH_O) \
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ from .fast_data_types import (
|
|||||||
glGetAttribLocation, glUseProgram, glBindVertexArray, GL_TEXTURE0,
|
glGetAttribLocation, glUseProgram, glBindVertexArray, GL_TEXTURE0,
|
||||||
GL_TEXTURE1, glGetIntegerv, GL_MAX_ARRAY_TEXTURE_LAYERS, glBufferData,
|
GL_TEXTURE1, glGetIntegerv, GL_MAX_ARRAY_TEXTURE_LAYERS, glBufferData,
|
||||||
GL_MAX_TEXTURE_SIZE, glDeleteTexture, GL_TEXTURE_2D_ARRAY, glGenTextures,
|
GL_MAX_TEXTURE_SIZE, glDeleteTexture, GL_TEXTURE_2D_ARRAY, glGenTextures,
|
||||||
glBindTexture, glTexParameteri, GL_LINEAR, GL_CLAMP_TO_EDGE,
|
glBindTexture, glTexParameteri, GL_LINEAR, GL_CLAMP_TO_EDGE, glDeleteBuffer,
|
||||||
GL_TEXTURE_MAG_FILTER, GL_TEXTURE_MIN_FILTER, GL_TEXTURE_WRAP_S,
|
GL_TEXTURE_MAG_FILTER, GL_TEXTURE_MIN_FILTER, GL_TEXTURE_WRAP_S,
|
||||||
GL_TEXTURE_WRAP_T, glGenBuffers, GL_R8, GL_RED, GL_UNPACK_ALIGNMENT, GL_UNSIGNED_BYTE,
|
GL_TEXTURE_WRAP_T, glGenBuffers, GL_R8, GL_RED, GL_UNPACK_ALIGNMENT, GL_UNSIGNED_BYTE,
|
||||||
GL_STATIC_DRAW, GL_TEXTURE_BUFFER, GL_RGB32UI, glBindBuffer, glPixelStorei,
|
GL_STATIC_DRAW, GL_TEXTURE_BUFFER, GL_RGB32UI, glBindBuffer, glPixelStorei,
|
||||||
@@ -89,6 +89,15 @@ class Sprites:
|
|||||||
self.texture_id = tex
|
self.texture_id = tex
|
||||||
glBindTexture(tgt, 0)
|
glBindTexture(tgt, 0)
|
||||||
|
|
||||||
|
def destroy(self):
|
||||||
|
if self.texture_id is not None:
|
||||||
|
glDeleteTexture(self.texture_id)
|
||||||
|
self.texture_id = None
|
||||||
|
if self.buffer_texture_id is not None:
|
||||||
|
glDeleteTexture(self.buffer_texture_id)
|
||||||
|
if self.buffer_id is not None:
|
||||||
|
glDeleteBuffer(self.buffer_id)
|
||||||
|
|
||||||
def ensure_state(self):
|
def ensure_state(self):
|
||||||
if self.texture_id is None:
|
if self.texture_id is None:
|
||||||
self.realloc_texture()
|
self.realloc_texture()
|
||||||
|
|||||||
Reference in New Issue
Block a user