From f542c5137df69a6f17e454e4537e4c858a364774 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Sun, 28 Apr 2013 23:49:27 -0400 Subject: [PATCH] Fix bug involving the condition string being removed when it shouldn't This bug occured when you selected from the mime type menu field while in attribute mode. The rows are removed and added again but the condition string view was left out because the menu item wasn't marked yet. Reordered to remove row, then set marked, then add row checking if marked and adding the condition string view based on the marked mime type. If no mime types are set it uses the first mimetype instead which is what we want in that case. --- src/kits/tracker/FindPanel.cpp | 40 ++++++++++++++++------------------ 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/src/kits/tracker/FindPanel.cpp b/src/kits/tracker/FindPanel.cpp index e9a9369345..659a5fb03e 100644 --- a/src/kits/tracker/FindPanel.cpp +++ b/src/kits/tracker/FindPanel.cpp @@ -1033,27 +1033,26 @@ FindPanel::Draw(BRect) return; for (int32 index = 0; index < fAttrGrid->CountRows(); index++) { - BMenuField* menuField = dynamic_cast(FindAttrView("MenuField", index)); if (menuField == NULL) - return; + continue; + BLayoutItem* stringView = fAttrGrid->ItemAt(1, index); BMenuItem* item = menuField->Menu()->FindMarked(); - if (item == NULL) - return; - - if (item->Submenu()->FindMarked()) { - BLayoutItem* stringView = fAttrGrid->ItemAt(1, index); - if (stringView == NULL) - stringView = fAttrGrid->AddView(new BStringView("", - item->Submenu()->FindMarked()->Label()), 1, index); - else - dynamic_cast(stringView->View())->SetText( - item->Submenu()->FindMarked()->Label()); + if (item == NULL || item->Submenu() == NULL + || item->Submenu()->FindMarked() == NULL) { + continue; + } + if (stringView == NULL) { + stringView = fAttrGrid->AddView(new BStringView("", + item->Submenu()->FindMarked()->Label()), 1, index); stringView->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT, B_ALIGN_VERTICAL_UNSET)); + } else { + dynamic_cast(stringView->View())->SetText( + item->Submenu()->FindMarked()->Label()); } } } @@ -1128,6 +1127,11 @@ FindPanel::MessageReceived(BMessage* message) case kMIMETypeItem: { + if (fMode == kByAttributeItem) { + // the attributes for this type may be different + RemoveAttrViewItems(false); + } + BMenuItem* item; if (message->FindPointer("source", (void**)&item) == B_OK) { // don't add the "All files and folders" to the list @@ -1137,15 +1141,9 @@ FindPanel::MessageReceived(BMessage* message) SetCurrentMimeType(item); } - // mime type switched - if (fMode != kByAttributeItem) - break; + if (fMode == kByAttributeItem) + AddAttrRow(); - // the attributes for this type may be different, - // rip out the existing ones - RemoveAttrViewItems(false); - - AddAttrRow(); break; }