1
0
Fork 0

DBG: allow duplicate hEntry for _plugin_menuaddentry

This commit is contained in:
mrexodia 2017-08-10 18:27:55 +02:00
parent 92850bd12f
commit 42b9b0f9dc
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
2 changed files with 6 additions and 13 deletions

View File

@ -614,9 +614,9 @@ int pluginmenuadd(int hMenu, const char* title)
/**
\brief Add a plugin menu entry to a menu.
\param hMenu The menu to add the entry to.
\param hEntry The handle you like to have the entry. This should be a unique value in the scope of the plugin that registered the \p hMenu.
\param hEntry The handle you like to have the entry. It cannot be -1
\param title The menu entry title.
\return true if the \p hEntry was unique and the entry was successfully added, false otherwise.
\return true if the entry was successfully added, false otherwise.
*/
bool pluginmenuaddentry(int hMenu, int hEntry, const char* title)
{
@ -635,10 +635,6 @@ bool pluginmenuaddentry(int hMenu, int hEntry, const char* title)
}
if(pluginHandle == -1) //not found
return false;
//search if hEntry was previously used
for(const auto & currentMenu : pluginMenuList)
if(currentMenu.pluginHandle == pluginHandle && currentMenu.hEntryPlugin == hEntry)
return false;
int hNewEntry = GuiMenuAddEntry(hMenu, title);
if(hNewEntry == -1)
return false;
@ -677,7 +673,6 @@ bool pluginmenuaddseparator(int hMenu)
bool pluginmenuclear(int hMenu, bool erase)
{
EXCLUSIVE_ACQUIRE(LockPluginMenuList);
bool bFound = false;
for(auto it = pluginMenuList.begin(); it != pluginMenuList.end(); ++it)
{
const auto & currentMenu = *it;
@ -685,13 +680,11 @@ bool pluginmenuclear(int hMenu, bool erase)
{
if(erase)
it = pluginMenuList.erase(it);
bFound = true;
GuiMenuClear(hMenu);
return true;
}
}
if(!bFound)
return false;
GuiMenuClear(hMenu);
return true;
return false;
}
/**

View File

@ -14,7 +14,7 @@ struct PLUG_MENU
{
int pluginHandle; //plugin handle
int hEntryMenu; //GUI entry/menu handle (unique)
int hEntryPlugin; //plugin entry handle (unique per plugin)
int hEntryPlugin; //plugin entry handle, -1 means it's a menu
};
struct PLUG_DATA