Tracker: Unchecked dynamic_cast, CID 1210857

This commit is contained in:
John Scipione 2014-07-24 22:42:50 -04:00
parent e85fa8f787
commit 350af1ce3f

View File

@ -2652,45 +2652,52 @@ FindPanel::AddAttributeControls(int32 gridRow)
void void
FindPanel::RestoreAttrState(const BMessage &message, int32 index) FindPanel::RestoreAttrState(const BMessage &message, int32 index)
{ {
BMenu* menu = dynamic_cast<BMenuField*>(FindAttrView("MenuField", index)) BMenuField* menuField
->Menu(); = dynamic_cast<BMenuField*>(FindAttrView("MenuField", index));
if (menuField != NULL) {
// decode menu selections // decode menu selections
BMenu* menu = menuField->Menu();
ASSERT(menu != NULL);
AddMimeTypeAttrs(menu); AddMimeTypeAttrs(menu);
const char* label; const char* label;
if (message.FindString("menuSelection", index, &label) == B_OK) { if (message.FindString("menuSelection", index, &label) == B_OK) {
int32 itemIndex = SelectItemWithLabel(menu, label); int32 itemIndex = SelectItemWithLabel(menu, label);
if (itemIndex >=0) { if (itemIndex >= 0) {
menu = menu->SubmenuAt(itemIndex); menu = menu->SubmenuAt(itemIndex);
if (menu && message.FindString("subMenuSelection", index, &label) if (menu != NULL && message.FindString("subMenuSelection",
== B_OK) index, &label) == B_OK) {
SelectItemWithLabel(menu, label); SelectItemWithLabel(menu, label);
} }
} }
}
}
// decode attribute text // decode attribute text
BString textEntryString = "TextEntry"; BString textEntryString = "TextEntry";
textEntryString << index; textEntryString << index;
BTextControl* textControl BTextControl* textControl = dynamic_cast<BTextControl*>(
= dynamic_cast<BTextControl*>(FindAttrView(textEntryString.String(), index)); FindAttrView(textEntryString.String(), index));
ASSERT(textControl != NULL); ASSERT(textControl != NULL);
const char* string; const char* string;
if (textControl != NULL && textControl->TextView() != NULL if (textControl != NULL
&& message.FindString("attrViewText", index, &string) == B_OK) { && message.FindString("attrViewText", index, &string) == B_OK) {
textControl->TextView()->SetText(string); textControl->SetText(string);
} }
int32 logicMenuSelectedIndex; int32 logicMenuSelectedIndex;
if (message.FindInt32("logicalRelation", index, if (message.FindInt32("logicalRelation", index,
&logicMenuSelectedIndex) == B_OK) { &logicMenuSelectedIndex) == B_OK) {
BMenuField* field = dynamic_cast<BMenuField*>(FindAttrView("Logic", index)); BMenuField* field = dynamic_cast<BMenuField*>(
FindAttrView("Logic", index));
if (field != NULL) { if (field != NULL) {
BMenu* fieldMenu = field->Menu(); BMenu* fieldMenu = field->Menu();
if (fieldMenu != NULL) { if (fieldMenu != NULL) {
BMenuItem* logicItem = fieldMenu->ItemAt(logicMenuSelectedIndex); BMenuItem* logicItem
= fieldMenu->ItemAt(logicMenuSelectedIndex);
if (logicItem != NULL) { if (logicItem != NULL) {
logicItem->SetMarked(true); logicItem->SetMarked(true);
return; return;