Fix memory leak of fonts, reduces memory usage by 3-5 MB.

Also fix caret not showing in servers list menu
This commit is contained in:
UnknownShadow200 2018-12-30 23:25:31 +11:00
parent f7364a0e63
commit 152a862f50
2 changed files with 13 additions and 11 deletions

View File

@ -1235,8 +1235,10 @@ static void ServersScreen_Tick(struct LScreen* s_) {
const static String refresh = String_FromConst("Refresh");
const static String failed = String_FromConst("&cFailed");
struct ServersScreen* s = (struct ServersScreen*)s_;
int count;
LScreen_Tick(s_);
int count = FetchFlagsTask.Count;
count = FetchFlagsTask.Count;
LWebTask_Tick(&FetchFlagsTask.Base);
/* TODO: Only redraw flags */
if (count != FetchFlagsTask.Count) LWidget_Draw(&s->Table);

View File

@ -990,6 +990,16 @@ static void Font_DirCallback(const String* path, void* obj) {
FT_Error err;
int i, flags;
/* Completely skip windows .FON files */
if (String_CaselessEnds(path, &fonExt)) return;
/* If font is already known good, skip it */
for (i = 0; i < font_list.Entries.Count; i++) {
entry = StringsBuffer_UNSAFE_Get(&font_list.Entries, i);
String_UNSAFE_Separate(&entry, font_list.Separator, &name, &fontPath);
if (String_CaselessEquals(path, &fontPath)) return;
}
if (!Font_MakeArgs(path, &stream, &args)) return;
/* For OSX font suitcase files */
@ -1001,16 +1011,6 @@ static void Font_DirCallback(const String* path, void* obj) {
args.pathname = filename.buffer;
#endif
/* If font is already known good, skip it */
for (i = 0; i < font_list.Entries.Count; i++) {
entry = StringsBuffer_UNSAFE_Get(&font_list.Entries, i);
String_UNSAFE_Separate(&entry, font_list.Separator, &name, &fontPath);
if (String_CaselessEquals(path, &fontPath)) return;
}
/* Completely skip windows .FON files */
if (String_CaselessEnds(path, &fonExt)) return;
err = FT_New_Face(ft_lib, &args, 0, &face);
if (err) { stream.close(&stream); return; }
flags = face->style_flags;