Skip to content

Commit

Permalink
Fix bug involving the condition string being removed when it shouldn't
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jscipione committed Apr 29, 2013
1 parent 2db4f18 commit f542c51
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions src/kits/tracker/FindPanel.cpp
Expand Up @@ -1033,27 +1033,26 @@ FindPanel::Draw(BRect)
return;

for (int32 index = 0; index < fAttrGrid->CountRows(); index++) {

BMenuField* menuField
= dynamic_cast<BMenuField*>(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<BStringView*>(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<BStringView*>(stringView->View())->SetText(
item->Submenu()->FindMarked()->Label());
}
}
}
Expand Down Expand Up @@ -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
Expand All @@ -1137,15 +1141,9 @@ FindPanel::MessageReceived(BMessage* message)
SetCurrentMimeType(item);
}

// mime type switched
if (fMode != kByAttributeItem)
break;

// the attributes for this type may be different,
// rip out the existing ones
RemoveAttrViewItems(false);
if (fMode == kByAttributeItem)
AddAttrRow();

AddAttrRow();
break;
}

Expand Down

0 comments on commit f542c51

Please sign in to comment.