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
+2 -2
View File
@@ -156,7 +156,7 @@ TBarView::TBarView(BRect frame, bool vertical, bool left, bool top,
AddChild(fDragRegion); AddChild(fDragRegion);
fExpandoMenuBar = new TExpandoMenuBar(BRect(0, 0, 0, 0), fExpandoMenuBar = new TExpandoMenuBar(BRect(0, 0, 0, 0),
"ExpandoMenuBar", fVertical); "ExpandoMenuBar", this, fVertical);
fInlineScrollView = new TInlineScrollView(BRect(0, 0, 0, 0), fInlineScrollView = new TInlineScrollView(BRect(0, 0, 0, 0),
fExpandoMenuBar, fVertical ? B_VERTICAL : B_HORIZONTAL); fExpandoMenuBar, fVertical ? B_VERTICAL : B_HORIZONTAL);
AddChild(fInlineScrollView); AddChild(fInlineScrollView);
@@ -764,7 +764,7 @@ TBarView::_ChangeState(BMessage* message)
} }
fExpandoMenuBar = new TExpandoMenuBar(BRect(0, 0, 0, 0), fExpandoMenuBar = new TExpandoMenuBar(BRect(0, 0, 0, 0),
"ExpandoMenuBar", fVertical); "ExpandoMenuBar", this, fVertical);
fInlineScrollView = new TInlineScrollView(BRect(0, 0, 0, 0), fInlineScrollView = new TInlineScrollView(BRect(0, 0, 0, 0),
fExpandoMenuBar, fVertical ? B_VERTICAL : B_HORIZONTAL); fExpandoMenuBar, fVertical ? B_VERTICAL : B_HORIZONTAL);
AddChild(fInlineScrollView); AddChild(fInlineScrollView);
+3 -3
View File
@@ -76,17 +76,18 @@ thread_id TExpandoMenuBar::sMonThread = B_ERROR;
BLocker TExpandoMenuBar::sMonLocker("expando monitor"); 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, BMenuBar(frame, name, B_FOLLOW_NONE,
vertical ? B_ITEMS_IN_COLUMN : B_ITEMS_IN_ROW), vertical ? B_ITEMS_IN_COLUMN : B_ITEMS_IN_ROW),
fBarView(barView),
fVertical(vertical), fVertical(vertical),
fOverflow(false), fOverflow(false),
fDrawLabel(!static_cast<TBarApp*>(be_app)->Settings()->hideLabels), fDrawLabel(!static_cast<TBarApp*>(be_app)->Settings()->hideLabels),
fShowTeamExpander(static_cast<TBarApp*>(be_app)->Settings()->superExpando), fShowTeamExpander(static_cast<TBarApp*>(be_app)->Settings()->superExpando),
fExpandNewTeams(static_cast<TBarApp*>(be_app)->Settings()->expandNewTeams), fExpandNewTeams(static_cast<TBarApp*>(be_app)->Settings()->expandNewTeams),
fDeskbarMenuWidth(kMinMenuItemWidth), fDeskbarMenuWidth(kMinMenuItemWidth),
fBarView(NULL),
fPreviousDragTargetItem(NULL), fPreviousDragTargetItem(NULL),
fLastClickedItem(NULL), fLastClickedItem(NULL),
fClickedExpander(false) fClickedExpander(false)
@@ -125,7 +126,6 @@ TExpandoMenuBar::AttachedToWindow()
{ {
BMenuBar::AttachedToWindow(); BMenuBar::AttachedToWindow();
fBarView = static_cast<TBarWindow*>(Window())->BarView();
fTeamList.MakeEmpty(); fTeamList.MakeEmpty();
if (fVertical) { if (fVertical) {
+2 -2
View File
@@ -62,7 +62,7 @@ enum drag_and_drop_selection {
class TExpandoMenuBar : public BMenuBar { class TExpandoMenuBar : public BMenuBar {
public: public:
TExpandoMenuBar(BRect frame, const char* name, TExpandoMenuBar(BRect frame, const char* name,
bool vertical); TBarView* barView, bool vertical);
virtual void AttachedToWindow(); virtual void AttachedToWindow();
virtual void DetachedFromWindow(); virtual void DetachedFromWindow();
@@ -103,6 +103,7 @@ private:
void _FinishedDrag(bool invoke = false); void _FinishedDrag(bool invoke = false);
private: private:
TBarView* fBarView;
bool fVertical : 1; bool fVertical : 1;
bool fOverflow : 1; bool fOverflow : 1;
bool fDrawLabel : 1; bool fDrawLabel : 1;
@@ -110,7 +111,6 @@ private:
bool fExpandNewTeams : 1; bool fExpandNewTeams : 1;
float fDeskbarMenuWidth; float fDeskbarMenuWidth;
TBarView* fBarView;
TTeamMenuItem* fPreviousDragTargetItem; TTeamMenuItem* fPreviousDragTargetItem;
BMenuItem* fLastMousedOverItem; BMenuItem* fLastMousedOverItem;
BMenuItem* fLastClickedItem; BMenuItem* fLastClickedItem;