From 95fee50c22037b11c41a662784c7423086f606a1 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 23 Apr 2008 11:38:08 +0930 Subject: [PATCH] xfree86: don't free the config-file related information in DIDR. #15645 In DeleteInputDeviceRequest, leave the conf_idev (which is shared with xf86ConfigLayout.input) alone for devices that were specified in the ServerLayout section of the config file. This way, in the next server generation we are left with what was the original config and can thus re-init the devices. This is an addon to 6d22a9615a0e6ab3d00b0bcb22ff001b6ece02ae, an attempt to fix Bug 14418. X.Org Bug 15645 X.Org Bug 14418 --- hw/xfree86/common/xf86Init.c | 60 +++++++++++++++++++-------------------- hw/xfree86/common/xf86Xinput.c | 18 +++++++++-- 2 files changed, 43 insertions(+), 35 deletions(-) diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index 6d5eaad..68dc387 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -1123,37 +1123,35 @@ InitInput(argc, argv) xf86Info.vtRequestsPending = FALSE; xf86Info.inputPending = FALSE; - if (serverGeneration == 1) { - /* Call the PreInit function for each input device instance. */ - for (pDev = xf86ConfigLayout.inputs; pDev && *pDev; pDev++) { - /* Replace obsolete keyboard driver with kbd */ - if (!xf86NameCmp((*pDev)->driver, "keyboard")) { - strcpy((*pDev)->driver, "kbd"); - } - - if ((pDrv = xf86LookupInputDriver((*pDev)->driver)) == NULL) { - xf86Msg(X_ERROR, "No Input driver matching `%s'\n", (*pDev)->driver); - /* XXX For now, just continue. */ - continue; - } - if (!pDrv->PreInit) { - xf86MsgVerb(X_WARNING, 0, - "Input driver `%s' has no PreInit function (ignoring)\n", - pDrv->driverName); - continue; - } - pInfo = pDrv->PreInit(pDrv, *pDev, 0); - if (!pInfo) { - xf86Msg(X_ERROR, "PreInit returned NULL for \"%s\"\n", - (*pDev)->identifier); - continue; - } else if (!(pInfo->flags & XI86_CONFIGURED)) { - xf86Msg(X_ERROR, "PreInit failed for input device \"%s\"\n", - (*pDev)->identifier); - xf86DeleteInput(pInfo, 0); - continue; - } - } + /* Call the PreInit function for each input device instance. */ + for (pDev = xf86ConfigLayout.inputs; pDev && *pDev; pDev++) { + /* Replace obsolete keyboard driver with kbd */ + if (!xf86NameCmp((*pDev)->driver, "keyboard")) { + strcpy((*pDev)->driver, "kbd"); + } + + if ((pDrv = xf86LookupInputDriver((*pDev)->driver)) == NULL) { + xf86Msg(X_ERROR, "No Input driver matching `%s'\n", (*pDev)->driver); + /* XXX For now, just continue. */ + continue; + } + if (!pDrv->PreInit) { + xf86MsgVerb(X_WARNING, 0, + "Input driver `%s' has no PreInit function (ignoring)\n", + pDrv->driverName); + continue; + } + pInfo = pDrv->PreInit(pDrv, *pDev, 0); + if (!pInfo) { + xf86Msg(X_ERROR, "PreInit returned NULL for \"%s\"\n", + (*pDev)->identifier); + continue; + } else if (!(pInfo->flags & XI86_CONFIGURED)) { + xf86Msg(X_ERROR, "PreInit failed for input device \"%s\"\n", + (*pDev)->identifier); + xf86DeleteInput(pInfo, 0); + continue; + } } /* Initialise all input devices. */ diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c index d34238e..710e787 100644 --- a/hw/xfree86/common/xf86Xinput.c +++ b/hw/xfree86/common/xf86Xinput.c @@ -448,6 +448,8 @@ DeleteInputDeviceRequest(DeviceIntPtr pDev) LocalDevicePtr pInfo = (LocalDevicePtr) pDev->public.devicePrivate; InputDriverPtr drv; IDevRec *idev; + BOOL found; + IDevPtr *it; if (pInfo) /* need to get these before RemoveDevice */ { @@ -464,10 +466,18 @@ DeleteInputDeviceRequest(DeviceIntPtr pDev) else xf86DeleteInput(pInfo, 0); - xfree(idev->driver); - xfree(idev->identifier); - xf86optionListFree(idev->commonOptions); - xfree(idev); + /* devices added through HAL aren't in the config layout */ + it = xf86ConfigLayout.inputs; + while(*it && *it != idev) + it++; + + if (!(*it)) /* end of list, not in the layout */ + { + xfree(idev->driver); + xfree(idev->identifier); + xf86optionListFree(idev->commonOptions); + xfree(idev); + } } /* -- 1.5.3