diff --git a/kitty/graphics.c b/kitty/graphics.c index a2af6ab21..3c73531a6 100644 --- a/kitty/graphics.c +++ b/kitty/graphics.c @@ -56,9 +56,17 @@ free_load_data(LoadData *ld) { ld->fd = -1; } +static inline void +free_image(Image *img) { + img->data_loaded = false; + // TODO: free the texture if texture_id is not zero + img->texture_id = 0; + free_load_data(&(img->load_data)); +} + GraphicsManager* grman_free(GraphicsManager* self) { - for (size_t i = 0; i < self->image_count; i++) free_load_data(&(self->images[i].load_data)); + for (size_t i = 0; i < self->image_count; i++) free_image(self->images + i); free(self->images); Py_TYPE(self)->tp_free((PyObject*)self); return NULL; @@ -101,12 +109,6 @@ remove_from_array(void *array, size_t item_size, size_t idx, size_t array_count) memset(p + (item_size * (array_count - 1)), 0, item_size); } -static inline void -free_image(Image *img) { - img->data_loaded = false; - free_load_data(&(img->load_data)); -} - static inline void remove_images(GraphicsManager *self, bool(*predicate)(Image*)) { for (size_t i = self->image_count; i-- > 0;) { diff --git a/kitty/graphics.h b/kitty/graphics.h index 9ca408896..64446c1be 100644 --- a/kitty/graphics.h +++ b/kitty/graphics.h @@ -27,7 +27,7 @@ typedef struct { } LoadData; typedef struct { - uint32_t gl_id, client_id, width, height; + uint32_t texture_id, client_id, width, height; size_t internal_id, refcnt; bool data_loaded;