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();
|
BMessage* message = Window()->CurrentMessage();
|
||||||
BMenuItem* menuItem;
|
BMenuItem* menuItem;
|
||||||
TTeamMenuItem* item = TeamItemAtPoint(where, &menuItem);
|
TTeamMenuItem* item = TeamItemAtPoint(where, &menuItem);
|
||||||
|
fLastClickedItem = item;
|
||||||
|
|
||||||
if (message == NULL || item == NULL || fBarView == NULL
|
if (message == NULL || item == NULL || fBarView == NULL
|
||||||
|| fBarView->Dragging()) {
|
|| fBarView->Dragging()) {
|
||||||
@@ -323,7 +324,6 @@ TExpandoMenuBar::MouseDown(BPoint where)
|
|||||||
if (Vertical() && static_cast<TBarApp*>(be_app)->Settings()->superExpando
|
if (Vertical() && static_cast<TBarApp*>(be_app)->Settings()->superExpando
|
||||||
&& item->ExpanderBounds().Contains(where)) {
|
&& item->ExpanderBounds().Contains(where)) {
|
||||||
// start the animation here, finish on mouse up
|
// start the animation here, finish on mouse up
|
||||||
fLastClickedItem = item;
|
|
||||||
item->SetArrowDirection(BControlLook::B_RIGHT_DOWN_ARROW);
|
item->SetArrowDirection(BControlLook::B_RIGHT_DOWN_ARROW);
|
||||||
SetMouseEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY);
|
SetMouseEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY);
|
||||||
Invalidate(item->ExpanderBounds());
|
Invalidate(item->ExpanderBounds());
|
||||||
@@ -341,7 +341,6 @@ TExpandoMenuBar::MouseDown(BPoint where)
|
|||||||
// absorb the message
|
// absorb the message
|
||||||
}
|
}
|
||||||
|
|
||||||
fLastClickedItem = item;
|
|
||||||
BMenuBar::MouseDown(where);
|
BMenuBar::MouseDown(where);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,9 +371,9 @@ TExpandoMenuBar::MouseMoved(BPoint where, uint32 code, const BMessage* message)
|
|||||||
? BControlLook::B_DOWN_ARROW
|
? BControlLook::B_DOWN_ARROW
|
||||||
: BControlLook::B_RIGHT_ARROW);
|
: BControlLook::B_RIGHT_ARROW);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Invalidate(lastItem->ExpanderBounds());
|
Invalidate(lastItem->ExpanderBounds());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (code) {
|
switch (code) {
|
||||||
@@ -482,13 +481,15 @@ TExpandoMenuBar::MouseMoved(BPoint where, uint32 code, const BMessage* message)
|
|||||||
void
|
void
|
||||||
TExpandoMenuBar::MouseUp(BPoint where)
|
TExpandoMenuBar::MouseUp(BPoint where)
|
||||||
{
|
{
|
||||||
|
TTeamMenuItem* lastItem = dynamic_cast<TTeamMenuItem*>(fLastClickedItem);
|
||||||
|
fLastClickedItem = NULL;
|
||||||
|
|
||||||
if (fBarView != NULL && fBarView->Dragging()) {
|
if (fBarView != NULL && fBarView->Dragging()) {
|
||||||
_FinishedDrag(true);
|
_FinishedDrag(true);
|
||||||
return;
|
return;
|
||||||
// absorb the message
|
// absorb the message
|
||||||
}
|
}
|
||||||
|
|
||||||
TTeamMenuItem* lastItem = dynamic_cast<TTeamMenuItem*>(fLastClickedItem);
|
|
||||||
if (lastItem != NULL && lastItem->ExpanderBounds().Contains(where)) {
|
if (lastItem != NULL && lastItem->ExpanderBounds().Contains(where)) {
|
||||||
lastItem->ToggleExpandState(true);
|
lastItem->ToggleExpandState(true);
|
||||||
lastItem->SetArrowDirection(lastItem->IsExpanded()
|
lastItem->SetArrowDirection(lastItem->IsExpanded()
|
||||||
|
|||||||
Reference in New Issue
Block a user