Free images in kitty when quitting diff kitten
This commit is contained in:
parent
a3f1d3e132
commit
fb9d95038d
@ -145,7 +145,7 @@ func (self *ImageCollection) ResizeForPageSize(width, height int) {
|
||||
}
|
||||
|
||||
func (self *ImageCollection) DeleteAllVisiblePlacements(lp *loop.Loop) {
|
||||
g := &GraphicsCommand{}
|
||||
g := self.new_graphics_command()
|
||||
g.SetAction(GRT_action_delete).SetDelete(GRT_delete_visible)
|
||||
g.WriteWithPayloadToLoop(lp, nil)
|
||||
}
|
||||
@ -172,7 +172,7 @@ func (self *ImageCollection) PlaceImageSubRect(lp *loop.Loop, key string, page_s
|
||||
}
|
||||
width = utils.Max(0, utils.Min(r.img.Width-left, width))
|
||||
height = utils.Max(0, utils.Min(r.img.Height-top, height))
|
||||
gc := &GraphicsCommand{}
|
||||
gc := self.new_graphics_command()
|
||||
gc.SetAction(GRT_action_display).SetLeftEdge(uint64(left)).SetTopEdge(uint64(top)).SetWidth(uint64(width)).SetHeight(uint64(height))
|
||||
gc.SetImageId(r.image_id).SetPlacementId(1).SetCursorMovement(GRT_cursor_static)
|
||||
gc.WriteWithPayloadToLoop(lp, nil)
|
||||
@ -183,9 +183,10 @@ func (self *ImageCollection) Initialize(lp *loop.Loop) {
|
||||
if tmux != "" && tui.TmuxAllowPassthrough() == nil {
|
||||
self.running_in_tmux = true
|
||||
}
|
||||
if !self.running_in_tmux {
|
||||
g := func(t GRT_t, payload string) uint32 {
|
||||
self.image_id_counter++
|
||||
g1 := &GraphicsCommand{}
|
||||
g1 := self.new_graphics_command()
|
||||
g1.SetTransmission(t).SetAction(GRT_action_query).SetImageId(self.image_id_counter).SetDataWidth(1).SetDataHeight(1).SetFormat(
|
||||
GRT_format_rgb).SetDataSize(uint64(len(payload)))
|
||||
g1.WriteWithPayloadToLoop(lp, utils.UnsafeStringToBytes(payload))
|
||||
@ -206,11 +207,23 @@ func (self *ImageCollection) Initialize(lp *loop.Loop) {
|
||||
self.temp_file_map[self.detection_shm_id] = &temp_resource{mmap: sf}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (self *ImageCollection) Finalize(lp *loop.Loop) {
|
||||
for _, tr := range self.temp_file_map {
|
||||
tr.remove()
|
||||
}
|
||||
for _, img := range self.images {
|
||||
for _, r := range img.renderings {
|
||||
if r.image_id > 0 {
|
||||
g := self.new_graphics_command()
|
||||
g.SetAction(GRT_action_delete).SetDelete(GRT_free_by_id).SetImageId(r.image_id)
|
||||
g.WriteWithPayloadToLoop(lp, nil)
|
||||
}
|
||||
}
|
||||
img.renderings = nil
|
||||
}
|
||||
self.images = nil
|
||||
}
|
||||
|
||||
var DebugPrintln = tty.DebugPrintln
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user