I’m trying to have an automatic sub menu to let the user access to a big number of files (over 2000)
So here is the code that gives me a crash ! There may be something which is not deleted, or, well I don’t know !
It happens if I close the plugin window while the menu is still showing…
[code]const int MOVIE_MENU_MAX_ITEM=40; // this is the max number of item inside each sub menus
PopupMenu m;
if (nb_Of_Sub_Menus==0)
{
…
(this part runs fine)
…
}
if (nb_Of_Sub_Menus>0)
{
PopupMenu* dialogMenu=new PopupMenu[nb_Of_Sub_Menus];
DirectoryIterator dir_iterator(File(OI->Movie_Path),false,T("*.kmv"),File::findFiles);
for (int sub=0;sub<nb_Of_Sub_Menus;sub++)
{
int count=1;
String s;
s.empty;
while((dir_iterator.next())&&(count++<=MOVIE_MENU_MAX_ITEM))
{
(dialogMenu[sub]).addItem (count,dir_iterator.getFile().getFileNameWithoutExtension());
}
s<<T("Movies ")<<((sub*MOVIE_MENU_MAX_ITEM)+1)<<T(" to ")<<(((sub+1)*MOVIE_MENU_MAX_ITEM));
m.addSubMenu (s, dialogMenu[sub]);
}
const int rc = m.show();
if (rc)
{
for (int sub=0;sub<nb_Of_Sub_Menus;sub++)
{
(dialogMenu[sub]).clear(); // I tried this to avoid the crash
}
return (rc-1);
}
else
{
for (int sub=0;sub<nb_Of_Sub_Menus;sub++)
{
(dialogMenu[sub]).clear();
}
return -1;
}
[/code]