diff options
Diffstat (limited to 'xorg-server/dix/dixfonts.c')
-rw-r--r-- | xorg-server/dix/dixfonts.c | 109 |
1 files changed, 74 insertions, 35 deletions
diff --git a/xorg-server/dix/dixfonts.c b/xorg-server/dix/dixfonts.c index 19fd31e3e..eb2c98c4b 100644 --- a/xorg-server/dix/dixfonts.c +++ b/xorg-server/dix/dixfonts.c @@ -124,6 +124,7 @@ SetDefaultFont(char *defaultfontname) int err; FontPtr pf; XID fid; + static FontPtr last_pf; fid = FakeClientID(0); err = OpenFont(serverClient, fid, FontLoadAll | FontOpenSync, @@ -132,9 +133,10 @@ SetDefaultFont(char *defaultfontname) return FALSE; err = dixLookupResourceByType((pointer *) &pf, fid, RT_FONT, serverClient, DixReadAccess); - if (err != Success) + if (err == Success) last_pf = pf; + if (last_pf == (FontPtr) NULL) return FALSE; - defaultFont = pf; + defaultFont = last_pf; return TRUE; } @@ -231,7 +233,8 @@ doOpenFont(ClientPtr client, OFclosurePtr c) char *alias, *newname; int newlen; int aliascount = 20; - + Bool fromDispatch = c->from_dispatch; + Bool finished = FALSE; /* * Decide at runtime what FontFormat to use. */ @@ -255,6 +258,8 @@ doOpenFont(ClientPtr client, OFclosurePtr c) #endif BitmapFormatScanlineUnit8; + c->from_dispatch = FALSE; + if (client->clientGone) { if (c->current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current_fpe]; @@ -354,13 +359,16 @@ doOpenFont(ClientPtr client, OFclosurePtr c) c->fontid, FontToXError(err)); } ClientWakeup(c->client); + finished = TRUE; xinerama_sleep: - for (i = 0; i < c->num_fpes; i++) { - FreeFPE(c->fpe_list[i]); + if (finished || fromDispatch) { + for (i = 0; i < c->num_fpes; i++) { + FreeFPE(c->fpe_list[i]); + } + free(c->fpe_list); + free(c->fontname); + free(c); } - free(c->fpe_list); - free(c->fontname); - free(c); return TRUE; } @@ -432,6 +440,7 @@ OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname, c->num_fpes = num_fpes; c->fnamelen = lenfname; c->flags = flags; + c->from_dispatch = TRUE; c->non_cachable_font = cached; (void) doOpenFont(client, c); @@ -558,6 +567,10 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) char *bufptr; char *bufferStart; int aliascount = 0; + Bool fromDispatch = c->from_dispatch; + Bool finished = FALSE; + + c->from_dispatch = FALSE; if (client->clientGone) { if (c->current.current_fpe < c->num_fpes) { @@ -778,13 +791,16 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) bail: ClientWakeup(client); + finished = TRUE; xinerama_sleep: - for (i = 0; i < c->num_fpes; i++) - FreeFPE(c->fpe_list[i]); - free(c->fpe_list); - free(c->savedName); - FreeFontNames(names); - free(c); + if (finished || fromDispatch) { + for (i = 0; i < c->num_fpes; i++) + FreeFPE(c->fpe_list[i]); + free(c->fpe_list); + free(c->savedName); + FreeFontNames(names); + free(c); + } free(resolved); return TRUE; } @@ -835,6 +851,7 @@ ListFonts(ClientPtr client, unsigned char *pattern, unsigned length, c->current.list_started = FALSE; c->current.private = 0; c->haveSaved = FALSE; + c->from_dispatch = TRUE; c->savedName = 0; doListFontsAndAliases(client, c); return Success; @@ -846,6 +863,8 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) FontPathElementPtr fpe; int err = Successful; char *name; + Bool fromDispatch = c->from_dispatch; + Bool finished = FALSE; int namelen; int numFonts; FontInfoRec fontInfo, *pFontInfo; @@ -856,6 +875,8 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) int aliascount = 0; xListFontsWithInfoReply finalReply; + c->from_dispatch = FALSE; + if (client->clientGone) { if (c->current.current_fpe < c->num_fpes) { fpe = c->fpe_list[c->current.current_fpe]; @@ -1029,13 +1050,16 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) WriteSwappedDataToClient(client, length, &finalReply); bail: ClientWakeup(client); + finished = TRUE; xinerama_sleep: - for (i = 0; i < c->num_fpes; i++) - FreeFPE(c->fpe_list[i]); - free(c->reply); - free(c->fpe_list); - free(c->savedName); - free(c); + if (finished || fromDispatch) { + for (i = 0; i < c->num_fpes; i++) + FreeFPE(c->fpe_list[i]); + free(c->reply); + free(c->fpe_list); + free(c->savedName); + free(c); + } return TRUE; } @@ -1082,6 +1106,7 @@ StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern, c->current.private = 0; c->savedNumFonts = 0; c->haveSaved = FALSE; + c->from_dispatch = TRUE; c->savedName = 0; doListFontsWithInfo(client, c); return Success; @@ -1091,7 +1116,7 @@ StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern, #define TextEltHeader 2 #define FontShiftSize 5 -static ChangeGCVal clearGC[] = { {.ptr = NullPixmap} }; +static ChangeGCVal clearGC[] = { NullPixmap }; #define clearGCmask (GCClipMask) @@ -1104,6 +1129,10 @@ doPolyText(ClientPtr client, PTclosurePtr c) FontPathElementPtr fpe; GC *origGC = NULL; int itemSize = c->reqType == X_PolyText8 ? 1 : 2; + Bool fromDispatch = c->from_dispatch; + Bool finished = FALSE; + + c->from_dispatch = FALSE; if (client->clientGone) { fpe = c->pGC->font->fpe; @@ -1341,16 +1370,19 @@ doPolyText(ClientPtr client, PTclosurePtr c) } if (ClientIsAsleep(client)) { ClientWakeup(c->client); + finished = TRUE; xinerama_sleep: - ChangeGC(NullClient, c->pGC, clearGCmask, clearGC); + if (finished || fromDispatch) { + ChangeGC(NullClient, c->pGC, clearGCmask, clearGC); - /* Unreference the font from the scratch GC */ - CloseFont(c->pGC->font, (Font) 0); - c->pGC->font = NullFont; + /* Unreference the font from the scratch GC */ + CloseFont(c->pGC->font, (Font) 0); + c->pGC->font = NullFont; - FreeScratchGC(c->pGC); - free(c->data); - free(c); + FreeScratchGC(c->pGC); + free(c->data); + free(c); + } } return TRUE; } @@ -1385,6 +1417,10 @@ doImageText(ClientPtr client, ITclosurePtr c) int err = Success, lgerr; /* err is in X error, not font error, space */ FontPathElementPtr fpe; int itemSize = c->reqType == X_ImageText8 ? 1 : 2; + Bool fromDispatch = c->from_dispatch; + Bool finished = FALSE; + + c->from_dispatch = FALSE; if (client->clientGone) { fpe = c->pGC->font->fpe; @@ -1485,16 +1521,19 @@ doImageText(ClientPtr client, ITclosurePtr c) } if (ClientIsAsleep(client)) { ClientWakeup(c->client); + finished = TRUE; xinerama_sleep: - ChangeGC(NullClient, c->pGC, clearGCmask, clearGC); + if (finished || fromDispatch) { + ChangeGC(NullClient, c->pGC, clearGCmask, clearGC); - /* Unreference the font from the scratch GC */ - CloseFont(c->pGC->font, (Font) 0); - c->pGC->font = NullFont; + /* Unreference the font from the scratch GC */ + CloseFont(c->pGC->font, (Font) 0); + c->pGC->font = NullFont; - FreeScratchGC(c->pGC); - free(c->data); - free(c); + FreeScratchGC(c->pGC); + free(c->data); + free(c); + } } return TRUE; } |