DBG: allow duplicate hEntry for _plugin_menuaddentry
This commit is contained in:
parent
92850bd12f
commit
42b9b0f9dc
|
@ -614,9 +614,9 @@ int pluginmenuadd(int hMenu, const char* title)
|
||||||
/**
|
/**
|
||||||
\brief Add a plugin menu entry to a menu.
|
\brief Add a plugin menu entry to a menu.
|
||||||
\param hMenu The menu to add the entry to.
|
\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.
|
\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)
|
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
|
if(pluginHandle == -1) //not found
|
||||||
return false;
|
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);
|
int hNewEntry = GuiMenuAddEntry(hMenu, title);
|
||||||
if(hNewEntry == -1)
|
if(hNewEntry == -1)
|
||||||
return false;
|
return false;
|
||||||
|
@ -677,7 +673,6 @@ bool pluginmenuaddseparator(int hMenu)
|
||||||
bool pluginmenuclear(int hMenu, bool erase)
|
bool pluginmenuclear(int hMenu, bool erase)
|
||||||
{
|
{
|
||||||
EXCLUSIVE_ACQUIRE(LockPluginMenuList);
|
EXCLUSIVE_ACQUIRE(LockPluginMenuList);
|
||||||
bool bFound = false;
|
|
||||||
for(auto it = pluginMenuList.begin(); it != pluginMenuList.end(); ++it)
|
for(auto it = pluginMenuList.begin(); it != pluginMenuList.end(); ++it)
|
||||||
{
|
{
|
||||||
const auto & currentMenu = *it;
|
const auto & currentMenu = *it;
|
||||||
|
@ -685,13 +680,11 @@ bool pluginmenuclear(int hMenu, bool erase)
|
||||||
{
|
{
|
||||||
if(erase)
|
if(erase)
|
||||||
it = pluginMenuList.erase(it);
|
it = pluginMenuList.erase(it);
|
||||||
bFound = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!bFound)
|
|
||||||
return false;
|
|
||||||
GuiMenuClear(hMenu);
|
GuiMenuClear(hMenu);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -14,7 +14,7 @@ struct PLUG_MENU
|
||||||
{
|
{
|
||||||
int pluginHandle; //plugin handle
|
int pluginHandle; //plugin handle
|
||||||
int hEntryMenu; //GUI entry/menu handle (unique)
|
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
|
struct PLUG_DATA
|
||||||
|
|
Loading…
Reference in New Issue