Compare commits

...

3 Commits

Author SHA1 Message Date
Francesco Abbate 6893cd7e29 Debug: add debug messages for memory leaks 2021-03-16 11:09:51 +01:00
Francesco Abbate 8ace5f6f77 Ensure SDL_Quit function is called on exit
Only for memory debugging purpose
2021-03-16 11:06:22 +01:00
Francesco Abbate 0cd1372b7f Remove unused data field in RenFont 2021-03-16 11:04:57 +01:00
3 changed files with 11 additions and 3 deletions

View File

@ -414,6 +414,7 @@ function core.init()
core.redraw = true
core.visited_files = {}
core.restart_request = false
core.quit_request = false
core.root_view = RootView()
core.command_view = CommandView()
@ -524,7 +525,7 @@ local function quit_with_function(quit_fn, force)
end
function core.quit(force)
quit_with_function(os.exit, force)
quit_with_function(function() core.quit_request = true end, force)
end
@ -853,12 +854,15 @@ function core.run()
core.frame_start = system.get_time()
local did_redraw = core.step()
local need_more_work = run_threads()
if core.restart_request then break end
if core.quit_request or core.restart_request then break end
if not did_redraw and not need_more_work then
idle_iterations = idle_iterations + 1
-- do not wait of events at idle_iterations = 1 to give a chance at core.step to run
-- and set "redraw" flag.
if idle_iterations > 1 then
collectgarbage()
local mk, mb = collectgarbage("count")
io.stderr:write(string.format("memory usage %g \r", mk))
if system.window_has_focus() then
-- keep running even with no events to make the cursor blinks
system.wait_event(frame_duration)

View File

@ -166,6 +166,9 @@ init_lua:
lua_close(L);
SDL_DestroyWindow(window);
SDL_Quit();
fprintf(stderr, "complete shutdown\n");
return EXIT_SUCCESS;
}

View File

@ -19,7 +19,6 @@ struct GlyphSet {
typedef struct GlyphSet GlyphSet;
struct RenFont {
void *data;
GlyphSet *sets[MAX_GLYPHSET];
float size;
int height;
@ -158,10 +157,12 @@ void ren_free_font(RenFont *font) {
for (int i = 0; i < MAX_GLYPHSET; i++) {
GlyphSet *set = font->sets[i];
if (set) {
fprintf(stderr, "free font bitmap: %d\n", i);
FR_Bitmap_Free(set->image);
free(set);
}
}
fprintf(stderr, "free font renderer\n");
FR_Renderer_Free(font->renderer);
free(font);
}