[PATCH] ephyr: Free damage structure at server reset time

Keith Packard keithp at keithp.com
Wed Jun 4 22:00:45 PDT 2014


The usual mechanism for freeing a damage structure when the pixmap is
destroyed does not work for the screen pixmap as it isn't freed in the
normal way.

The existing driver cleanup function, scrfini, is called after the
wrapped CloseScreen functions, including damageCloseScreen, are called
and thus ephyr can't free the damage structure at that point.

Deal with this by providing an early CloseScreen hook in KdCloseScreen
which ephyr can use to free the damage structure before damage itself
shuts down.

Signed-off-by: Keith Packard <keithp at keithp.com>
---
 hw/kdrive/ephyr/ephyr.c     | 6 ++++++
 hw/kdrive/ephyr/ephyr.h     | 3 +++
 hw/kdrive/ephyr/ephyrinit.c | 2 ++
 hw/kdrive/src/kdrive.c      | 4 ++++
 hw/kdrive/src/kdrive.h      | 1 +
 5 files changed, 16 insertions(+)

diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index def50d8..49a4d2d 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -756,6 +756,12 @@ ephyrScreenFini(KdScreenInfo * screen)
     }
 }
 
+void
+ephyrCloseScreen(ScreenPtr pScreen)
+{
+    ephyrUnsetInternalDamage(pScreen);
+}
+
 /*  
  * Port of Mark McLoughlin's Xnest fix for focus in + modifier bug.
  * See https://bugs.freedesktop.org/show_bug.cgi?id=3030
diff --git a/hw/kdrive/ephyr/ephyr.h b/hw/kdrive/ephyr/ephyr.h
index 34ce460..e691780 100644
--- a/hw/kdrive/ephyr/ephyr.h
+++ b/hw/kdrive/ephyr/ephyr.h
@@ -131,6 +131,9 @@ void
  ephyrScreenFini(KdScreenInfo * screen);
 
 void
+ephyrCloseScreen(ScreenPtr pScreen);
+
+void
  ephyrCardFini(KdCardInfo * card);
 
 void
diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c
index fac84cd..3f66e1c 100644
--- a/hw/kdrive/ephyr/ephyrinit.c
+++ b/hw/kdrive/ephyr/ephyrinit.c
@@ -430,4 +430,6 @@ KdCardFuncs ephyrFuncs = {
 
     ephyrGetColors,             /* getColors */
     ephyrPutColors,             /* putColors */
+
+    ephyrCloseScreen,           /* closeScreen */
 };
diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c
index 9814fc6..b5b91c0 100644
--- a/hw/kdrive/src/kdrive.c
+++ b/hw/kdrive/src/kdrive.c
@@ -621,8 +621,12 @@ KdCloseScreen(ScreenPtr pScreen)
     KdCardInfo *card = pScreenPriv->card;
     Bool ret;
 
+    if (card->cfuncs->closeScreen)
+        (*card->cfuncs->closeScreen)(pScreen);
+
     pScreenPriv->closed = TRUE;
     pScreen->CloseScreen = pScreenPriv->CloseScreen;
+
     if (pScreen->CloseScreen)
         ret = (*pScreen->CloseScreen) (pScreen);
     else
diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h
index bec75cb..08b1681 100644
--- a/hw/kdrive/src/kdrive.h
+++ b/hw/kdrive/src/kdrive.h
@@ -130,6 +130,7 @@ typedef struct _KdCardFuncs {
     void (*getColors) (ScreenPtr, int, xColorItem *);
     void (*putColors) (ScreenPtr, int, xColorItem *);
 
+    void (*closeScreen) (ScreenPtr);    /* close ScreenRec */
 } KdCardFuncs;
 
 #define KD_MAX_PSEUDO_DEPTH 8
-- 
2.0.0.rc4



More information about the xorg-devel mailing list