DeskBar: misplaced NULL check
- Main problem was that lastItem was accidentally used outside of a NULL check - Also cleanup initialization and reset of fLastClickedItem (it is now valid from mousedown on an item to either mouseup, or when the team dies) Fixes #15991 Change-Id: I82e30303c50a61b9d44c092347f067dcb1105006 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2619 Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
committed by
Adrien Destugues
parent
24337d5342
commit
2edfb7b145
@@ -256,6 +256,7 @@ TExpandoMenuBar::MouseDown(BPoint where)
|
||||
BMessage* message = Window()->CurrentMessage();
|
||||
BMenuItem* menuItem;
|
||||
TTeamMenuItem* item = TeamItemAtPoint(where, &menuItem);
|
||||
fLastClickedItem = item;
|
||||
|
||||
if (message == NULL || item == NULL || fBarView == NULL
|
||||
|| fBarView->Dragging()) {
|
||||
@@ -323,7 +324,6 @@ TExpandoMenuBar::MouseDown(BPoint where)
|
||||
if (Vertical() && static_cast<TBarApp*>(be_app)->Settings()->superExpando
|
||||
&& item->ExpanderBounds().Contains(where)) {
|
||||
// start the animation here, finish on mouse up
|
||||
fLastClickedItem = item;
|
||||
item->SetArrowDirection(BControlLook::B_RIGHT_DOWN_ARROW);
|
||||
SetMouseEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY);
|
||||
Invalidate(item->ExpanderBounds());
|
||||
@@ -341,7 +341,6 @@ TExpandoMenuBar::MouseDown(BPoint where)
|
||||
// absorb the message
|
||||
}
|
||||
|
||||
fLastClickedItem = item;
|
||||
BMenuBar::MouseDown(where);
|
||||
}
|
||||
|
||||
@@ -372,9 +371,9 @@ TExpandoMenuBar::MouseMoved(BPoint where, uint32 code, const BMessage* message)
|
||||
? BControlLook::B_DOWN_ARROW
|
||||
: BControlLook::B_RIGHT_ARROW);
|
||||
}
|
||||
}
|
||||
|
||||
Invalidate(lastItem->ExpanderBounds());
|
||||
Invalidate(lastItem->ExpanderBounds());
|
||||
}
|
||||
}
|
||||
|
||||
switch (code) {
|
||||
@@ -482,13 +481,15 @@ TExpandoMenuBar::MouseMoved(BPoint where, uint32 code, const BMessage* message)
|
||||
void
|
||||
TExpandoMenuBar::MouseUp(BPoint where)
|
||||
{
|
||||
TTeamMenuItem* lastItem = dynamic_cast<TTeamMenuItem*>(fLastClickedItem);
|
||||
fLastClickedItem = NULL;
|
||||
|
||||
if (fBarView != NULL && fBarView->Dragging()) {
|
||||
_FinishedDrag(true);
|
||||
return;
|
||||
// absorb the message
|
||||
}
|
||||
|
||||
TTeamMenuItem* lastItem = dynamic_cast<TTeamMenuItem*>(fLastClickedItem);
|
||||
if (lastItem != NULL && lastItem->ExpanderBounds().Contains(where)) {
|
||||
lastItem->ToggleExpandState(true);
|
||||
lastItem->SetArrowDirection(lastItem->IsExpanded()
|
||||
|
||||
Reference in New Issue
Block a user