> Avoid null font > > This patch avoids the case where a requested font is not found. It first tries > to load the default font, or exuts with an error. Note that the original patch > entirely removes the two wfree statements. I've added them back as it seemed > to > be the Right Thing to do. > > Submitted by: Gilbert Ashley <[email protected]> > Author: unknown
I think I am the author :-) http://repo.or.cz/w/wmaker-crm.git?a=commit;h=ee28b0257ab5d61a2ba8fb9108e74447d7c9fde9 and the commit log there is more verbose as to what I was trying to fix (maybe too verbose, but I easily forget what I did in the past and the reasons for doing, so I prefer to be verbose rather than to not know my motivations) But this patch was NAK'ed by Dan before (I think in this mailing list). His reason was that one should not modify the library to not return NULL, but instead check for NULL in the caller site. I quite agree with him. But I never had the motivation again to fix it properly as Dan suggested, though. > Origin: ALT/Sisyphus Linux, Alexey Voinov <[email protected]> > > diff --git a/WINGs/wfont.c b/WINGs/wfont.c > --- a/WINGs/wfont.c > +++ b/WINGs/wfont.c > @@ -159,10 +159,19 @@ > > font->font = XftFontOpenName(display, scrPtr->screen, fname); > if (!font->font) { > - wfree(font); > - wfree(fname); > - return NULL; > + printf("Font named %s doesn't exist.\n", fname); > + printf("Please check your system configuration.\n"); > + printf("Will try default font %s.\n", DEFAULT_FONT); > + font->font = XftFontOpenName(display, scrPtr->screen, DEFAULT_FONT); > + if (!font->font) { > + printf("Unrecoverable font error! I must die!\n"); > + wfree(font); > + wfree(fname); > + exit(1); > + } else > + printf("Default font loading succeded.\n"); > } > + > font->height = font->font->ascent+font->font->descent; > font->y = font->font->ascent; > -- To unsubscribe, send mail to [email protected].
