Xi: Fix pointer handling in KeyClassRec copy.
We don't free the class anymore, so just store the previous pointers, do the memcpy from the SD and then restore the pointers. Plugs a memleak too, before xkbInfo was never freed.
This commit is contained in:
parent
755f9e5d78
commit
3c4c9938f3
|
@ -438,13 +438,36 @@ DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to)
|
||||||
memcpy(to->field, from->field, sizeof(type)); \
|
memcpy(to->field, from->field, sizeof(type)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
ALLOC_COPY_CLASS_IF(key, KeyClassRec);
|
if (from->key)
|
||||||
if (to->key && from->key)
|
|
||||||
{
|
{
|
||||||
|
KeyCode *oldModKeyMap;
|
||||||
|
KeySym *oldMap;
|
||||||
#ifdef XKB
|
#ifdef XKB
|
||||||
to->key->xkbInfo = NULL;
|
struct _XkbSrvInfo *oldXkbInfo;
|
||||||
#endif
|
#endif
|
||||||
to->key->curKeySyms.map = NULL;
|
|
||||||
|
if (!to->key)
|
||||||
|
{
|
||||||
|
to->key = xcalloc(1, sizeof(KeyClassRec));
|
||||||
|
if (!to->key)
|
||||||
|
FatalError("[Xi] no memory for class shift.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
oldModKeyMap = to->key->modifierKeyMap;
|
||||||
|
oldMap = to->key->curKeySyms.map;
|
||||||
|
#ifdef XKB
|
||||||
|
oldXkbInfo = to->key->xkbInfo;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
memcpy(to->key, from->key, sizeof(KeyClassRec));
|
||||||
|
|
||||||
|
to->key->modifierKeyMap = oldModKeyMap;
|
||||||
|
to->key->curKeySyms.map = oldMap;
|
||||||
|
#ifdef XKB
|
||||||
|
to->key->xkbInfo = oldXkbInfo;
|
||||||
|
#endif
|
||||||
|
|
||||||
CopyKeyClass(from, to);
|
CopyKeyClass(from, to);
|
||||||
} else if (to->key && !from->key)
|
} else if (to->key && !from->key)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue