mirror of
https://github.com/gryf/wmaker.git
synced 2026-02-05 15:55:56 +01:00
fixed memory leaks and crash with deminiaturization
This commit is contained in:
35
src/misc.c
35
src/misc.c
@@ -1164,6 +1164,19 @@ keysymToString(KeySym keysym, unsigned int state)
|
||||
}
|
||||
#endif
|
||||
|
||||
static char *
|
||||
appendrealloc(char *a, char *b)
|
||||
{
|
||||
if (a == NULL)
|
||||
return wstrdup(b);
|
||||
else {
|
||||
char *c = wstrappend(a, b);
|
||||
free(a);
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char*
|
||||
GetShortcutString(char *text)
|
||||
{
|
||||
@@ -1189,33 +1202,33 @@ GetShortcutString(char *text)
|
||||
modmask |= mod;
|
||||
|
||||
if (strcasecmp(text, "Meta")==0) {
|
||||
buffer = wstrappend(buffer, "M+");
|
||||
buffer = appendrealloc(buffer, "M+");
|
||||
} else if (strcasecmp(text, "Alt")==0) {
|
||||
buffer = wstrappend(buffer, "A+");
|
||||
buffer = appendrealloc(buffer, "A+");
|
||||
} else if (strcasecmp(text, "Shift")==0) {
|
||||
buffer = wstrappend(buffer, "Sh+");
|
||||
buffer = appendrealloc(buffer, "Sh+");
|
||||
} else if (strcasecmp(text, "Mod1")==0) {
|
||||
buffer = wstrappend(buffer, "M1+");
|
||||
buffer = appendrealloc(buffer, "M1+");
|
||||
} else if (strcasecmp(text, "Mod2")==0) {
|
||||
buffer = wstrappend(buffer, "M2+");
|
||||
buffer = appendrealloc(buffer, "M2+");
|
||||
} else if (strcasecmp(text, "Mod3")==0) {
|
||||
buffer = wstrappend(buffer, "M3+");
|
||||
buffer = appendrealloc(buffer, "M3+");
|
||||
} else if (strcasecmp(text, "Mod4")==0) {
|
||||
buffer = wstrappend(buffer, "M4+");
|
||||
buffer = appendrealloc(buffer, "M4+");
|
||||
} else if (strcasecmp(text, "Mod5")==0) {
|
||||
buffer = wstrappend(buffer, "M5+");
|
||||
buffer = appendrealloc(buffer, "M5+");
|
||||
} else if (strcasecmp(text, "Control")==0) {
|
||||
control = 1;
|
||||
} else {
|
||||
buffer = wstrappend(buffer, text);
|
||||
buffer = appendrealloc(buffer, text);
|
||||
}
|
||||
text = k+1;
|
||||
}
|
||||
|
||||
if (control) {
|
||||
buffer = wstrappend(buffer, "^");
|
||||
buffer = appendrealloc(buffer, "^");
|
||||
}
|
||||
buffer = wstrappend(buffer, text);
|
||||
buffer = appendrealloc(buffer, text);
|
||||
|
||||
/* get key */
|
||||
/* ksym = XStringToKeysym(text);
|
||||
|
||||
Reference in New Issue
Block a user