dix: free the unused device classes when closing a device.
This also requires to NULL-ify all pointers while we're actually using them, otherwise we'd try to free them twice.
This commit is contained in:
parent
48d33ab9b6
commit
51c8fd69ec
|
@ -519,7 +519,8 @@ DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to)
|
||||||
to->key = xcalloc(1, sizeof(KeyClassRec));
|
to->key = xcalloc(1, sizeof(KeyClassRec));
|
||||||
if (!to->key)
|
if (!to->key)
|
||||||
FatalError("[Xi] no memory for class shift.\n");
|
FatalError("[Xi] no memory for class shift.\n");
|
||||||
}
|
} else
|
||||||
|
classes->key = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
oldModKeyMap = to->key->modifierKeyMap;
|
oldModKeyMap = to->key->modifierKeyMap;
|
||||||
|
@ -562,6 +563,8 @@ DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to)
|
||||||
classes = dixLookupPrivate(&to->devPrivates,
|
classes = dixLookupPrivate(&to->devPrivates,
|
||||||
UnusedClassesPrivateKey);
|
UnusedClassesPrivateKey);
|
||||||
to->valuator = classes->valuator;
|
to->valuator = classes->valuator;
|
||||||
|
if (to->valuator)
|
||||||
|
classes->valuator = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
to->valuator = xrealloc(to->valuator, sizeof(ValuatorClassRec) +
|
to->valuator = xrealloc(to->valuator, sizeof(ValuatorClassRec) +
|
||||||
|
@ -600,7 +603,8 @@ DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to)
|
||||||
to->button = xcalloc(1, sizeof(ButtonClassRec));
|
to->button = xcalloc(1, sizeof(ButtonClassRec));
|
||||||
if (!to->button)
|
if (!to->button)
|
||||||
FatalError("[Xi] no memory for class shift.\n");
|
FatalError("[Xi] no memory for class shift.\n");
|
||||||
}
|
} else
|
||||||
|
classes->button = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
to->button->buttonsDown = 0;
|
to->button->buttonsDown = 0;
|
||||||
|
@ -650,7 +654,9 @@ DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to)
|
||||||
to->focus = xcalloc(1, sizeof(FocusClassRec));
|
to->focus = xcalloc(1, sizeof(FocusClassRec));
|
||||||
if (!to->focus)
|
if (!to->focus)
|
||||||
FatalError("[Xi] no memory for class shift.\n");
|
FatalError("[Xi] no memory for class shift.\n");
|
||||||
}
|
} else
|
||||||
|
classes->focus = NULL;
|
||||||
|
|
||||||
oldTrace = to->focus->trace;
|
oldTrace = to->focus->trace;
|
||||||
memcpy(to->focus, from->focus, sizeof(FocusClassRec));
|
memcpy(to->focus, from->focus, sizeof(FocusClassRec));
|
||||||
to->focus->trace = xrealloc(oldTrace,
|
to->focus->trace = xrealloc(oldTrace,
|
||||||
|
@ -680,7 +686,8 @@ DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to)
|
||||||
to->proximity = xcalloc(1, sizeof(ProximityClassRec));
|
to->proximity = xcalloc(1, sizeof(ProximityClassRec));
|
||||||
if (!to->proximity)
|
if (!to->proximity)
|
||||||
FatalError("[Xi] no memory for class shift.\n");
|
FatalError("[Xi] no memory for class shift.\n");
|
||||||
}
|
} else
|
||||||
|
classes->proximity = NULL;
|
||||||
}
|
}
|
||||||
memcpy(to->proximity, from->proximity, sizeof(ProximityClassRec));
|
memcpy(to->proximity, from->proximity, sizeof(ProximityClassRec));
|
||||||
} else if (to->proximity)
|
} else if (to->proximity)
|
||||||
|
@ -703,7 +710,8 @@ DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to)
|
||||||
to->absolute = xcalloc(1, sizeof(AbsoluteClassRec));
|
to->absolute = xcalloc(1, sizeof(AbsoluteClassRec));
|
||||||
if (!to->absolute)
|
if (!to->absolute)
|
||||||
FatalError("[Xi] no memory for class shift.\n");
|
FatalError("[Xi] no memory for class shift.\n");
|
||||||
}
|
} else
|
||||||
|
classes->absolute = NULL;
|
||||||
}
|
}
|
||||||
memcpy(to->absolute, from->absolute, sizeof(AbsoluteClassRec));
|
memcpy(to->absolute, from->absolute, sizeof(AbsoluteClassRec));
|
||||||
} else if (to->absolute)
|
} else if (to->absolute)
|
||||||
|
@ -713,7 +721,6 @@ DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to)
|
||||||
classes->absolute = to->absolute;
|
classes->absolute = to->absolute;
|
||||||
to->absolute = NULL;
|
to->absolute = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -775,6 +775,13 @@ CloseDevice(DeviceIntPtr dev)
|
||||||
classes = (ClassesPtr)&dev->key;
|
classes = (ClassesPtr)&dev->key;
|
||||||
FreeAllDeviceClasses(classes);
|
FreeAllDeviceClasses(classes);
|
||||||
|
|
||||||
|
if (dev->isMaster)
|
||||||
|
{
|
||||||
|
classes = dixLookupPrivate(&dev->devPrivates, UnusedClassesPrivateKey);
|
||||||
|
FreeAllDeviceClasses(classes);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef XKB
|
#ifdef XKB
|
||||||
while (dev->xkb_interest)
|
while (dev->xkb_interest)
|
||||||
XkbRemoveResourceClient((DevicePtr)dev,dev->xkb_interest->resource);
|
XkbRemoveResourceClient((DevicePtr)dev,dev->xkb_interest->resource);
|
||||||
|
|
Loading…
Reference in New Issue