turns out trying to access the position of a closed window results in an x error

who could've known
This commit is contained in:
Jill 2023-06-02 15:37:38 +03:00
parent 7fcf926426
commit 49ce6885ea
Signed by: oat
GPG Key ID: 33489AA58A955108
2 changed files with 5 additions and 1 deletions

View File

@ -40,7 +40,9 @@ class Funfriend::ChatterContext < Funfriend::WindowContext
def update_position
if parent
p = parent.not_nil!
window.position = (Vec2.new(p.window.position) + Vec2.new(p.window.size) / 2 + parent_relative_pos - window_size / 2).xy_i
if !p.closed
window.position = (Vec2.new(p.window.position) + Vec2.new(p.window.size) / 2 + parent_relative_pos - window_size / 2).xy_i
end
end
end

View File

@ -5,6 +5,7 @@ GLFW_FOCUS_ON_SHOW = 0x0002000C
class Funfriend::WindowContext
getter window : CrystGLFW::Window
property closed : Bool = false
DEFAULT_HINTS = {
# supposedly required on MacOS
@ -43,6 +44,7 @@ class Funfriend::WindowContext
def close
window.destroy
@closed = true
end
def clean_up