- bugfix: idaapi.del_menu_item() was failing to delete some menu items

This commit is contained in:
elias.bachaalany 2011-05-19 15:06:49 +00:00
parent a12974b66c
commit 7e63ea0747
2 changed files with 12 additions and 7 deletions

View File

@ -5,14 +5,14 @@ def cb(*args):
return 1
try:
ctx
idaapi.del_menu_item(ctx)
ex_addmenu_item_ctx
idaapi.del_menu_item(ex_addmenu_item_ctx)
print("Menu removed")
del ctx
del ex_addmenu_item_ctx
except:
ctx = idaapi.add_menu_item("Search/", "X", "", 0, cb, tuple("hello world"))
if ctx is None:
ex_addmenu_item_ctx = idaapi.add_menu_item("Search/", "X", "", 0, cb, tuple("hello world"))
if ex_addmenu_item_ctx is None:
print("Failed to add menu!")
del ctx
del ex_addmenu_item_ctx
else:
print("Menu added successfully. Run the script again to delete the menu")

View File

@ -298,6 +298,11 @@ static PyObject *py_add_menu_item(
{
bool no_args;
// No slash in the menu path?
const char *p = strrchr(menupath, '/');
if ( p == NULL )
Py_RETURN_NONE;
if ( args == Py_None )
{
no_args = true;
@ -334,7 +339,7 @@ static PyObject *py_add_menu_item(
py_add_del_menu_item_ctx *ctx = new py_add_del_menu_item_ctx();
// Form the complete menu path
ctx->menupath = menupath;
ctx->menupath.append(menupath, p - menupath + 1);
ctx->menupath.append(name);
// Save callback data
ctx->cb_data = cb_data;