crsfml
crsfml copied to clipboard
double free
I think this problem might be related to crsfml, so I post here as well. Here is the original page: https://forum.crystal-lang.org/t/double-free-or-corruption-prev/4811
Recently I want to write a program to read script files like this: https://pastebin.com/nKMS14fX
I know little about C, so as the 'double free'. And I am confused. Here is my code: (it truly takes time for me to locate the problematic function, since this error msg has no traceback...)
def ArcaeaInspector.update_txt(new_text : String, line_num : Int32)
case line_num
when 0
tx = @@txta
when 1
tx = @@txtb
when 2
tx = @@txtc
end
tx = tx.not_nil!
tx.string = new_text
lb = tx.local_bounds
tx.origin = SF.vector2f lb.left + lb.width / 2, lb.top + lb.height / 2
tx.position = SF.vector2f(
@@window.size.x / 2,
@@window.size.y - @@window.size.y / 5 + line_num * 20)
end
Here is where this func is called:
def say(content : Array(String))
ArcaeaInspector.clear_txt
i = -1
content.each do |t|
SF.sleep SF.seconds 1.5
i += 1
ArcaeaInspector.update_txt t, i
end
SF.sleep SF.seconds 1
ArcaeaInspector.show_arrow
end
The code is at my github repository
By the way, I've also tried run the program in release mode, and the error exists still. What's more, this occurs "sometimes". If I'm luck enough