diff options
author | Peter Hutterer <peter@cs.unisa.edu.au> | 2008-04-13 16:52:14 +0930 |
---|---|---|
committer | Peter Hutterer <peter@cs.unisa.edu.au> | 2008-04-13 17:00:00 +0930 |
commit | 3c4c9938f31755c5a59995fdcfa138c99db76bbf (patch) | |
tree | cdf4d15fc79b2b9a6706639bda5aea319b445716 /Xi | |
parent | 755f9e5d7898056cf3bead69ce25a10e23995582 (diff) |
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.
Diffstat (limited to 'Xi')
-rw-r--r-- | Xi/exevents.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c index cf0e8984b..aee78c669 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -438,13 +438,36 @@ DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to) memcpy(to->field, from->field, sizeof(type)); \ } - ALLOC_COPY_CLASS_IF(key, KeyClassRec); - if (to->key && from->key) + if (from->key) { + KeyCode *oldModKeyMap; + KeySym *oldMap; #ifdef XKB - to->key->xkbInfo = NULL; + struct _XkbSrvInfo *oldXkbInfo; #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); } else if (to->key && !from->key) { |