asmagill / hammerspoon_asm

Hammerspoon modules in progress...
MIT License
52 stars 12 forks source link

No way to "destroy" hs._asm.touchbar? #10

Closed latenitefilms closed 7 years ago

latenitefilms commented 7 years ago

@asmagill - There doesn't currently seem to be any way to "destroy" a hs._asm.touchbar?

For example, if I do:

touchbar = require("hs._asm.touchbar")
example = touchbar.new()
example:show()
example = nil

The Touch Bar will still be visible on screen. I'm assuming this shouldn't be the case? Is this the garbage collection issue you were talking about?

asmagill commented 7 years ago

I'll have to check it closer... the issue as I recall it is that what we're actually capturing is a live stream from the "display" which maintains the touch bar. I can stop the stream, which __gc does, but if I actually release it (it's a Core Foundation object, so in theory, I'm supposed to release it myself since ARC won't) then Hammerspoon crashes.

However, it should at least stop the stream and hide it, so I'll have to figure out why you still see it... have you issued collectgarbage() after setting it to nil?

latenitefilms commented 7 years ago

Ah, right - adding collectgarbage() fixes it. Thanks!