From 4cb7bfb343eccc5baf7d7c330fd1bb3ee28cfac6 Mon Sep 17 00:00:00 2001
From: "Dietmar M. Zettl" <dietmar@Arthur.zettl-home.net>
Date: Thu, 1 Feb 2018 18:42:38 +0100
Subject: [PATCH] Fix for Bug 103662 - Xserv aborts with __glXExtensionInit:
 AddExtensions failed.

Signed-off-by: Dietmar M. Zettl <dietmar@Arthur.zettl-home.net>
---
 hw/xquartz/quartz.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index c8ea3bf8b..672334a90 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -165,6 +165,21 @@ static const ExtensionModule quartzExtensions[] = {
  */
 static void QuartzExtensionInit(void)
 {
+    /*
+     * Ensure similar to AddStaticExtensions in miinitext.c
+     * that quartzExtensions are initialised only once.
+     * Otherwise the GLX extension gets appended to the global list of
+     * extension every time the server restarts resulting in multiple 
+     * additions of the GLX extension module subsequently leading to the error
+     * Not enabling extension GLX: maximum number of events or errors exceeded.
+     */
+
+    static Bool listInitialised = FALSE;
+
+    if (listInitialised)
+        return;
+    listInitialised = TRUE;
+
     LoadExtensionList(quartzExtensions, ARRAY_SIZE(quartzExtensions), TRUE);
 }
 
@@ -178,7 +193,6 @@ QuartzInitOutput(int argc,
 {
     /* For XQuartz, we want to just use the default signal handler to work better with CrashTracer */
     signal(SIGSEGV, SIG_DFL);
-    signal(SIGABRT, SIG_DFL);
     signal(SIGILL, SIG_DFL);
 #ifdef SIGEMT
     signal(SIGEMT, SIG_DFL);
@@ -301,8 +315,8 @@ QuartzUpdateScreens(void)
 
     quartzProcs->UpdateScreen(pScreen);
 
-    /* PaintWindow needs to be called after RootlessUpdateScreenPixmap (from xprUpdateScreen) */
-    pScreen->PaintWindow(pRoot, &pRoot->borderClip, PW_BACKGROUND);
+    /* miPaintWindow needs to be called after RootlessUpdateScreenPixmap (from xprUpdateScreen) */
+    miPaintWindow(pRoot, &pRoot->borderClip, PW_BACKGROUND);
 
     /* Tell RandR about the new size, so new connections get the correct info */
     RRScreenSizeNotify(pScreen);
-- 
2.13.5 (Apple Git-94)

