diff --git a/src/apps/icon-o-matic/generic/property/view/PropertyListView.cpp b/src/apps/icon-o-matic/generic/property/view/PropertyListView.cpp index 436202103f..d43d6087f2 100644 --- a/src/apps/icon-o-matic/generic/property/view/PropertyListView.cpp +++ b/src/apps/icon-o-matic/generic/property/view/PropertyListView.cpp @@ -11,7 +11,6 @@ #include #include -#include #include #ifdef __HAIKU__ # include @@ -191,8 +190,8 @@ PropertyListView::MessageReceived(BMessage* message) if (!archivable) continue; // see if this is actually a property - Property* property = cast_as(archivable, Property); - if (!property || !propertyObject.AddProperty(property)) + Property* property = dynamic_cast(archivable); + if (property == NULL || !propertyObject.AddProperty(property)) delete archivable; } if (propertyObject.CountProperties() > 0) diff --git a/src/apps/mail/ComboBox.cpp b/src/apps/mail/ComboBox.cpp index fccc89c775..a9c60f34fa 100644 --- a/src/apps/mail/ComboBox.cpp +++ b/src/apps/mail/ComboBox.cpp @@ -64,7 +64,6 @@ All rights reserved. */ #include -#include #include #include #include @@ -613,8 +612,7 @@ BComboBox::TextInput::KeyDown(const char *bytes, int32 numBytes) switch (aKey) { case B_RETURN: - cb = cast_as(Parent(), BComboBox); - + cb = dynamic_cast(Parent()); ASSERT(cb); if (!cb->IsEnabled()) @@ -639,7 +637,7 @@ BComboBox::TextInput::KeyDown(const char *bytes, int32 numBytes) } break; case B_TAB: -// cb = cast_as(Parent(), BComboBox); +// cb = dynamic_castParent()); // ASSERT(cb); // if (cb->fAutoComplete && cb->fCompletionIndex >= 0) { // int32 from, to; @@ -678,10 +676,10 @@ BComboBox::TextInput::KeyDown(const char *bytes, int32 numBytes) #if 0 case B_UP_ARROW: // fall through case B_DOWN_ARROW: - cb = cast_as(Parent(), BComboBox); + cb = dynamic_cast(Parent()); ASSERT(cb); if (cb->fChoiceList) { - cb = cast_as(Parent(), BComboBox); + cb = dynamic_cast(Parent()); ASSERT(cb); if (!(cb->fPopupWindow)) { cb->fPopupWindow = cb->CreatePopupWindow(); @@ -709,11 +707,11 @@ BComboBox::TextInput::KeyDown(const char *bytes, int32 numBytes) break; #endif case B_ESCAPE: - cb = cast_as(Parent(), BComboBox); + cb = dynamic_cast(Parent()); ASSERT(cb); if (cb->fChoiceList) { - cb = cast_as(Parent(), BComboBox); + cb = dynamic_cast(Parent()); ASSERT(cb); if (cb->fPopupWindow && cb->fPopupWindow->Lock()) { @@ -749,7 +747,7 @@ BComboBox::TextInput::MakeFocus(bool state) if (state == IsFocus()) return; - BComboBox* parent = cast_as(Parent(), BComboBox); + BComboBox* parent = dynamic_cast(Parent()); ASSERT(parent); BTextView::MakeFocus(state); diff --git a/src/preferences/sounds/HWindow.cpp b/src/preferences/sounds/HWindow.cpp index d6295517e2..eed9cf3f66 100644 --- a/src/preferences/sounds/HWindow.cpp +++ b/src/preferences/sounds/HWindow.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -173,7 +172,10 @@ HWindow::MessageReceived(BMessage* message) switch (message->what) { case M_OTHER_MESSAGE: { - BMenuField* menufield = cast_as(FindView("filemenu"), BMenuField); + BMenuField* menufield + = dynamic_cast(FindView("filemenu")); + if (menufield == NULL) + return; BMenu* menu = menufield->Menu(); HEventRow* row = (HEventRow*)fEventList->CurrentSelection(); @@ -199,8 +201,10 @@ HWindow::MessageReceived(BMessage* message) entry_ref ref; HEventRow* row = (HEventRow*)fEventList->CurrentSelection(); if (message->FindRef("refs", &ref) == B_OK && row != NULL) { - BMenuField* menufield = cast_as(FindView("filemenu"), - BMenuField); + BMenuField* menufield + = dynamic_cast(FindView("filemenu")); + if (menufield == NULL) + return; BMenu* menu = menufield->Menu(); // check audio file @@ -267,7 +271,10 @@ HWindow::MessageReceived(BMessage* message) case M_EVENT_CHANGED: { const char* path; - BMenuField* menufield = cast_as(FindView("filemenu"), BMenuField); + BMenuField* menufield + = dynamic_cast(FindView("filemenu")); + if (menufield == NULL) + return; BMenu* menu = menufield->Menu(); if (message->FindString("path", &path) == B_OK) { @@ -308,7 +315,9 @@ HWindow::MessageReceived(BMessage* message) void HWindow::SetupMenuField() { - BMenuField* menufield = cast_as(FindView("filemenu"), BMenuField); + BMenuField* menufield = dynamic_cast(FindView("filemenu")); + if (menufield == NULL) + return; BMenu* menu = menufield->Menu(); int32 count = fEventList->CountRows(); for (int32 i = 0; i < count; i++) { @@ -403,11 +412,11 @@ void HWindow::Pulse() { HEventRow* row = (HEventRow*)fEventList->CurrentSelection(); - BMenuField* menufield = cast_as(FindView("filemenu"), BMenuField); - BButton* button = cast_as(FindView("play"), BButton); - BButton* stop = cast_as(FindView("stop"), BButton); + BMenuField* menufield = dynamic_cast(FindView("filemenu")); + BButton* button = dynamic_cast(FindView("play")); + BButton* stop = dynamic_cast(FindView("stop")); - if (menufield == NULL) + if (menufield == NULL || button == NULL || stop == NULL) return; if (row != NULL) {