Pass a pointer to the TBarView object into the ExpandoMenuBar constructor

I fear that perhaps the fBarView variable may be accessed before it has a
chance to be set in AttachedToWindow(). By setting it in the constructor there
is no chance of this. Might fix #9656
This commit is contained in:
John Scipione 2013-04-10 15:23:17 -04:00
parent e0d1980015
commit b76cec7d9c
3 changed files with 7 additions and 7 deletions

View File

@ -156,7 +156,7 @@ TBarView::TBarView(BRect frame, bool vertical, bool left, bool top,
AddChild(fDragRegion);
fExpandoMenuBar = new TExpandoMenuBar(BRect(0, 0, 0, 0),
"ExpandoMenuBar", fVertical);
"ExpandoMenuBar", this, fVertical);
fInlineScrollView = new TInlineScrollView(BRect(0, 0, 0, 0),
fExpandoMenuBar, fVertical ? B_VERTICAL : B_HORIZONTAL);
AddChild(fInlineScrollView);
@ -764,7 +764,7 @@ TBarView::_ChangeState(BMessage* message)
}
fExpandoMenuBar = new TExpandoMenuBar(BRect(0, 0, 0, 0),
"ExpandoMenuBar", fVertical);
"ExpandoMenuBar", this, fVertical);
fInlineScrollView = new TInlineScrollView(BRect(0, 0, 0, 0),
fExpandoMenuBar, fVertical ? B_VERTICAL : B_HORIZONTAL);
AddChild(fInlineScrollView);

View File

@ -76,17 +76,18 @@ thread_id TExpandoMenuBar::sMonThread = B_ERROR;
BLocker TExpandoMenuBar::sMonLocker("expando monitor");
TExpandoMenuBar::TExpandoMenuBar(BRect frame, const char* name, bool vertical)
TExpandoMenuBar::TExpandoMenuBar(BRect frame, const char* name,
TBarView* barView, bool vertical)
:
BMenuBar(frame, name, B_FOLLOW_NONE,
vertical ? B_ITEMS_IN_COLUMN : B_ITEMS_IN_ROW),
fBarView(barView),
fVertical(vertical),
fOverflow(false),
fDrawLabel(!static_cast<TBarApp*>(be_app)->Settings()->hideLabels),
fShowTeamExpander(static_cast<TBarApp*>(be_app)->Settings()->superExpando),
fExpandNewTeams(static_cast<TBarApp*>(be_app)->Settings()->expandNewTeams),
fDeskbarMenuWidth(kMinMenuItemWidth),
fBarView(NULL),
fPreviousDragTargetItem(NULL),
fLastClickedItem(NULL),
fClickedExpander(false)
@ -125,7 +126,6 @@ TExpandoMenuBar::AttachedToWindow()
{
BMenuBar::AttachedToWindow();
fBarView = static_cast<TBarWindow*>(Window())->BarView();
fTeamList.MakeEmpty();
if (fVertical) {

View File

@ -62,7 +62,7 @@ enum drag_and_drop_selection {
class TExpandoMenuBar : public BMenuBar {
public:
TExpandoMenuBar(BRect frame, const char* name,
bool vertical);
TBarView* barView, bool vertical);
virtual void AttachedToWindow();
virtual void DetachedFromWindow();
@ -103,6 +103,7 @@ private:
void _FinishedDrag(bool invoke = false);
private:
TBarView* fBarView;
bool fVertical : 1;
bool fOverflow : 1;
bool fDrawLabel : 1;
@ -110,7 +111,6 @@ private:
bool fExpandNewTeams : 1;
float fDeskbarMenuWidth;
TBarView* fBarView;
TTeamMenuItem* fPreviousDragTargetItem;
BMenuItem* fLastMousedOverItem;
BMenuItem* fLastClickedItem;