Fix crash when dragging files onto nav menus.

- BNavMenu now keeps its own copy of the cached types list that's passed to it.
  In some circumstances it could happen that the container window would
  delete the list and consequently the nav menu would wind up with a pointer
  to an invalid object. Probably a regression from the async mouse tracking
  rewrites.
This commit is contained in:
Rene Gollent 2012-09-03 16:24:28 -04:00
parent 1d6d4b7872
commit 9335e141ba
2 changed files with 14 additions and 9 deletions

View File

@ -80,12 +80,12 @@ class BNavMenu : public BSlowMenu {
BWindow *parentWindow = NULL, const BObjectList<BString> *list = NULL);
// parentWindow, if specified, will be closed if nav menu item invoked
// with option held down
virtual ~BNavMenu();
virtual void AttachedToWindow();
virtual void DetachedFromWindow();
void SetNavDir(const entry_ref *);
void ForceRebuild();
bool NeedsToRebuild() const;
@ -96,7 +96,7 @@ class BNavMenu : public BSlowMenu {
BMessenger Target();
void SetTypesList(const BObjectList<BString> *list);
const BObjectList<BString> *TypesList() const;
const BObjectList<BString> *TypesList() const;
void AddNavDir(const Model *model, uint32 what, BHandler *target,
bool populateSubmenu);
@ -121,7 +121,7 @@ class BNavMenu : public BSlowMenu {
protected:
virtual bool StartBuildingItemList();
virtual bool AddNextItem();
virtual void DoneBuildingItemList();
virtual void DoneBuildingItemList();
virtual void ClearMenuBuildingState();
void BuildVolumeMenu();
@ -142,7 +142,7 @@ class BNavMenu : public BSlowMenu {
EntryListBase *fContainer;
bool fIteratingDesktop;
const BObjectList<BString> *fTypesList;
BObjectList<BString> *fTypesList;
TrackingHookData fTrackingHook;
};

View File

@ -263,8 +263,10 @@ BNavMenu::BNavMenu(const char* title, uint32 message, const BHandler* target,
fFlags(0),
fItemList(0),
fContainer(0),
fTypesList(list)
fTypesList(new BObjectList<BString>(10, true))
{
if (list != NULL)
*fTypesList = *list;
InitIconPreloader();
SetFont(be_plain_font);
@ -292,8 +294,10 @@ BNavMenu::BNavMenu(const char* title, uint32 message,
fFlags(0),
fItemList(0),
fContainer(0),
fTypesList(list)
fTypesList(new BObjectList<BString>(10, true))
{
if (list != NULL)
*fTypesList = *list;
InitIconPreloader();
SetFont(be_plain_font);
@ -313,6 +317,7 @@ BNavMenu::BNavMenu(const char* title, uint32 message,
BNavMenu::~BNavMenu()
{
delete fTypesList;
}
@ -814,7 +819,7 @@ BNavMenu::SetShowParent(bool show)
void
BNavMenu::SetTypesList(const BObjectList<BString>* list)
{
fTypesList = list;
*fTypesList = *list;
}