Failproofshark / cl-sdl2-ttf

A common lisp wrapper for SDL2_TTF used for loading fonts and creating text assets
25 stars 19 forks source link

Add weakref set for opened fonts, close them on quit #17

Closed pkulev closed 4 years ago

pkulev commented 5 years ago

I've added weakref set for opened fonts to prevent any errors on closing library having refs to fonts in client code. Here's example: 1) We're creating ref to cl-sdl2-ttf font object - https://github.com/pkulev/o2/blob/7a9927d49e5d1ea74c891c6b37feb9d0c0ea8a3c/src/application.lisp#L95 2) We're closing fonts on quit before quitting SDL libraries - https://github.com/pkulev/o2/blob/7a9927d49e5d1ea74c891c6b37feb9d0c0ea8a3c/src/application.lisp#L125 3) Font already closed in cl-sdl2-ttf library, but our code still has ref to it or something. 4) Here we're quitting cl-sdl2-ttf library - https://github.com/pkulev/o2/blob/7a9927d49e5d1ea74c891c6b37feb9d0c0ea8a3c/src/application.lisp#L151 5) After that steps finalizers come to play and everything blows up.

Now with weakrefs library itself can close fonts if they are not closed, or just skip them if they are already closed from client code.

Also I've added fix for proper repo language determination, now it will be determined as CL, not python :smiley:

Failproofshark commented 4 years ago

Hello Puklev. Sorry for seeing this so late! Thanks for the contribution!