Переглянути джерело

Disable entries instead of shuffling memory around

Less risk for bugs this way.
tags/v1.4.90
Pierre Ossman 9 роки тому
джерело
коміт
52a18150a7
1 змінених файлів з 11 додано та 22 видалено
  1. 11
    22
      vncviewer/Viewport.cxx

+ 11
- 22
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);
}


Завантаження…
Відмінити
Зберегти