From: Pierre Ossman Date: Fri, 20 Feb 2015 16:34:49 +0000 (+0100) Subject: Disable entries instead of shuffling memory around X-Git-Tag: v1.4.90~41 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=52a18150a7a8f2802000136c35005bc83b5b0855;p=tigervnc.git Disable entries instead of shuffling memory around Less risk for bugs this way. --- diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx index 918730e6..463523f5 100644 --- a/vncviewer/Viewport.cxx +++ b/vncviewer/Viewport.cxx @@ -1109,31 +1109,20 @@ void Viewport::initContextMenu() if (menuAltKey) items[i].flags |= FL_MENU_VALUE; break; + case ID_MENUKEY: + // The menu key needs to have its fields updated, or the entries hidden + if (!menuKeySym) + items[i].flags |= FL_MENU_INACTIVE | FL_MENU_INVISIBLE; + else if (!(items[i].flags & FL_MENU_INVISIBLE)) { + char sendMenuKey[64]; + snprintf(sendMenuKey, 64, _("Send %s"), (const char *)menuKey); + free((void*)items[i].text); + items[i].text = strdup(sendMenuKey); + } + break; } } - // The menu key needs to have its fields updated, or the entries removed - for (i = 0;i < sizeof(items)/sizeof(items[0]);i++) { - char sendMenuKey[64]; - - if ((intptr_t)items[i].user_data_ != ID_MENUKEY) - continue; - - if (!menuKeySym) { - memmove(items + i, items + i + 1, - sizeof(items) - (sizeof(items[0]) * (i+1))); - i--; - continue; - } - - if (items[i].flags & FL_MENU_INVISIBLE) - continue; - - snprintf(sendMenuKey, 64, _("Send %s"), (const char *)menuKey); - free((void*)items[i].text); - items[i].text = strdup(sendMenuKey); - } - contextMenu->copy(items); }