BFilePanel: fix items from favorites menu not working

Regression from hrev57294.

The code introduced there relies on the state of the "open" button being
updated from a previous selection in the file panel. But that is no the
case if the B_REFS_RECEIVED message does not come from the file panel
(in this case it comes directly from the favorites menu).

Fixes #18627.

Change-Id: Ic12b1989a4fbd631ce048aa6286d4d7c60ab1d99
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7577
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
This commit is contained in:
PulkoMandy 2024-03-31 13:12:19 +02:00 committed by waddlesplash
parent 1f09e28c68
commit 57ad6e6f34
1 changed files with 10 additions and 7 deletions

View File

@ -1230,7 +1230,7 @@ TFilePanel::MessageReceived(BMessage* message)
switch (message->what) {
case B_REFS_RECEIVED:
// item was double clicked in file panel (PoseView)
// item was double clicked in file panel (PoseView) or from the favorites menu
if (message->FindRef("refs", &ref) == B_OK) {
BEntry entry(&ref, true);
if (entry.InitCheck() == B_OK) {
@ -1247,12 +1247,15 @@ TFilePanel::MessageReceived(BMessage* message)
SwitchDirMenuTo(&ref);
} else {
// Otherwise, we have a file or a link to a file.
// AdjustButton has already tested the flavor;
// all we have to do is see if the button is enabled.
BButton* button = dynamic_cast<BButton*>(
FindView("default button"));
if (button == NULL || !button->IsEnabled())
break;
// AdjustButton has already tested the flavor if it comes from the file
// panel; all we have to do is see if the button is enabled.
// In other cases, however, we can't rely on that. So first check for
// TrackerViewToken in the message to see if it's coming from the pose view
if (message->HasMessenger("TrackerViewToken")) {
BButton* button = dynamic_cast<BButton*>(FindView("default button"));
if (button == NULL || !button->IsEnabled())
break;
}
if (IsSavePanel()) {
int32 count = 0;