(!1711) exa: simplify CreatePixmap()/DestroyPixmap() handlers error pathes
Instead of complex wrap/unwrap trickery in the error path, just protect the DestroyPixmap() handlers from half-initialized state. This not just makes the code flow simpler and easier to understand, but also clears the road for decoupling the extension specific pixmap destructor logic from the ScreenRec proc vectors (*1). *1) see: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1755 Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
53e81d6c35
commit
22a614a05c
|
@ -96,10 +96,7 @@ exaCreatePixmap_classic(ScreenPtr pScreen, int w, int h, int depth,
|
|||
pExaPixmap->fb_size = pExaPixmap->fb_pitch * h;
|
||||
|
||||
if (pExaPixmap->fb_pitch > 131071) {
|
||||
swap(pExaScr, pScreen, DestroyPixmap);
|
||||
if (pScreen->DestroyPixmap)
|
||||
pScreen->DestroyPixmap(pPixmap);
|
||||
swap(pExaScr, pScreen, DestroyPixmap);
|
||||
dixDestroyPixmap(pPixmap, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -109,10 +106,7 @@ exaCreatePixmap_classic(ScreenPtr pScreen, int w, int h, int depth,
|
|||
pScreen, pPixmap);
|
||||
|
||||
if (pExaPixmap->pDamage == NULL) {
|
||||
swap(pExaScr, pScreen, DestroyPixmap);
|
||||
if (pScreen->DestroyPixmap)
|
||||
pScreen->DestroyPixmap(pPixmap);
|
||||
swap(pExaScr, pScreen, DestroyPixmap);
|
||||
dixDestroyPixmap(pPixmap, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -218,6 +212,8 @@ exaDestroyPixmap_classic(PixmapPtr pPixmap)
|
|||
|
||||
if (pPixmap->refcnt == 1) {
|
||||
ExaPixmapPriv(pPixmap);
|
||||
if (!pExaPixmap) // we're called on an error path
|
||||
goto out;
|
||||
|
||||
exaDestroyPixmap(pPixmap);
|
||||
|
||||
|
@ -235,6 +231,7 @@ exaDestroyPixmap_classic(PixmapPtr pPixmap)
|
|||
RegionUninit(&pExaPixmap->validFB);
|
||||
}
|
||||
|
||||
out:
|
||||
swap(pExaScr, pScreen, DestroyPixmap);
|
||||
if (pScreen->DestroyPixmap)
|
||||
ret = pScreen->DestroyPixmap(pPixmap);
|
||||
|
|
|
@ -98,10 +98,7 @@ exaCreatePixmap_driver(ScreenPtr pScreen, int w, int h, int depth,
|
|||
}
|
||||
|
||||
if (!pExaPixmap->driverPriv) {
|
||||
swap(pExaScr, pScreen, DestroyPixmap);
|
||||
if (pScreen->DestroyPixmap)
|
||||
pScreen->DestroyPixmap(pPixmap);
|
||||
swap(pExaScr, pScreen, DestroyPixmap);
|
||||
dixDestroyPixmap(pPixmap, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -196,6 +193,8 @@ exaDestroyPixmap_driver(PixmapPtr pPixmap)
|
|||
|
||||
if (pPixmap->refcnt == 1) {
|
||||
ExaPixmapPriv(pPixmap);
|
||||
if (!pExaPixmap) // we're called on an error path
|
||||
goto out;
|
||||
|
||||
exaDestroyPixmap(pPixmap);
|
||||
|
||||
|
@ -204,6 +203,7 @@ exaDestroyPixmap_driver(PixmapPtr pPixmap)
|
|||
pExaPixmap->driverPriv = NULL;
|
||||
}
|
||||
|
||||
out:
|
||||
swap(pExaScr, pScreen, DestroyPixmap);
|
||||
if (pScreen->DestroyPixmap)
|
||||
ret = pScreen->DestroyPixmap(pPixmap);
|
||||
|
|
|
@ -249,6 +249,8 @@ exaDestroyPixmap_mixed(PixmapPtr pPixmap)
|
|||
|
||||
if (pPixmap->refcnt == 1) {
|
||||
ExaPixmapPriv(pPixmap);
|
||||
if (!pExaPixmap)
|
||||
goto out; // we're called on an error path
|
||||
|
||||
exaDestroyPixmap(pPixmap);
|
||||
|
||||
|
@ -266,6 +268,7 @@ exaDestroyPixmap_mixed(PixmapPtr pPixmap)
|
|||
}
|
||||
}
|
||||
|
||||
out:
|
||||
swap(pExaScr, pScreen, DestroyPixmap);
|
||||
if (pScreen->DestroyPixmap)
|
||||
ret = pScreen->DestroyPixmap(pPixmap);
|
||||
|
|
Loading…
Reference in New Issue