[haiku-commits] r35600 - in haiku/trunk/src: apps/icon-o-matic/generic/property/view apps/mail preferences/sounds

  • From: alex@xxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 24 Feb 2010 15:10:18 +0100 (CET)

Author: aldeck
Date: 2010-02-24 15:10:17 +0100 (Wed, 24 Feb 2010)
New Revision: 35600
Changeset: http://dev.haiku-os.org/changeset/35600/haiku

Modified:
   haiku/trunk/src/apps/icon-o-matic/generic/property/view/PropertyListView.cpp
   haiku/trunk/src/apps/mail/ComboBox.cpp
   haiku/trunk/src/preferences/sounds/HWindow.cpp
Log:
* more cleanup in Sounds preflet, replaced occurences of the deprecated cast_as 
macro, added missing checks.
* took the opportunity to do the same for all occurences as reported by 
OpenGrok 


Modified: 
haiku/trunk/src/apps/icon-o-matic/generic/property/view/PropertyListView.cpp
===================================================================
--- 
haiku/trunk/src/apps/icon-o-matic/generic/property/view/PropertyListView.cpp    
    2010-02-24 14:08:54 UTC (rev 35599)
+++ 
haiku/trunk/src/apps/icon-o-matic/generic/property/view/PropertyListView.cpp    
    2010-02-24 14:10:17 UTC (rev 35600)
@@ -11,7 +11,6 @@
 #include <stdio.h>
 #include <string.h>
 
-#include <ClassInfo.h>
 #include <Clipboard.h>
 #ifdef __HAIKU__
 #  include <LayoutUtils.h>
@@ -191,8 +190,8 @@
                                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<Property*>(archivable);
+                               if (property == NULL || 
!propertyObject.AddProperty(property))
                                        delete archivable;
                        }
                        if (propertyObject.CountProperties() > 0)

Modified: haiku/trunk/src/apps/mail/ComboBox.cpp
===================================================================
--- haiku/trunk/src/apps/mail/ComboBox.cpp      2010-02-24 14:08:54 UTC (rev 
35599)
+++ haiku/trunk/src/apps/mail/ComboBox.cpp      2010-02-24 14:10:17 UTC (rev 
35600)
@@ -64,7 +64,6 @@
 */
 
 #include <Button.h>
-#include <ClassInfo.h>
 #include <Debug.h>
 #include <InterfaceDefs.h>
 #include <ListItem.h>
@@ -613,8 +612,7 @@
 
        switch (aKey) {
                case B_RETURN:
-                       cb = cast_as(Parent(), BComboBox);
-
+                       cb = dynamic_cast<BComboBox*>(Parent());
                        ASSERT(cb);
 
                        if (!cb->IsEnabled())
@@ -639,7 +637,7 @@
                        }
                        break;
                case B_TAB:
-//                     cb = cast_as(Parent(), BComboBox);
+//                     cb = dynamic_cast<BComboBox*>Parent());
 //                     ASSERT(cb);
 //                     if (cb->fAutoComplete && cb->fCompletionIndex >= 0) {   
 //                             int32 from, to;
@@ -678,10 +676,10 @@
 #if 0
                case B_UP_ARROW:                // fall through
                case B_DOWN_ARROW:
-                       cb = cast_as(Parent(), BComboBox);
+                       cb = dynamic_cast<BComboBox*>(Parent());
                        ASSERT(cb);
                        if (cb->fChoiceList) {
-                               cb = cast_as(Parent(), BComboBox);
+                               cb = dynamic_cast<BComboBox*>(Parent());
                                ASSERT(cb);
                                if (!(cb->fPopupWindow)) {
                                        cb->fPopupWindow = 
cb->CreatePopupWindow();
@@ -709,11 +707,11 @@
                        break;
 #endif
                case B_ESCAPE:
-                       cb = cast_as(Parent(), BComboBox);
+                       cb = dynamic_cast<BComboBox*>(Parent());
                        ASSERT(cb);
                        if (cb->fChoiceList)
                        {
-                               cb = cast_as(Parent(), BComboBox);
+                               cb = dynamic_cast<BComboBox*>(Parent());
                                ASSERT(cb);
                                if (cb->fPopupWindow && 
cb->fPopupWindow->Lock())
                                {
@@ -749,7 +747,7 @@
        if (state == IsFocus())
                return;
 
-       BComboBox* parent = cast_as(Parent(), BComboBox);
+       BComboBox* parent = dynamic_cast<BComboBox*>(Parent());
        ASSERT(parent);
 
        BTextView::MakeFocus(state);

Modified: haiku/trunk/src/preferences/sounds/HWindow.cpp
===================================================================
--- haiku/trunk/src/preferences/sounds/HWindow.cpp      2010-02-24 14:08:54 UTC 
(rev 35599)
+++ haiku/trunk/src/preferences/sounds/HWindow.cpp      2010-02-24 14:10:17 UTC 
(rev 35600)
@@ -19,7 +19,6 @@
 #include <Beep.h>
 #include <Box.h>
 #include <Button.h>
-#include <ClassInfo.h>
 #include <FindDirectory.h>
 #include <fs_attr.h>
 #include <MediaFiles.h>
@@ -173,7 +172,10 @@
        switch (message->what) {
                case M_OTHER_MESSAGE:
                {
-                       BMenuField* menufield = cast_as(FindView("filemenu"), 
BMenuField);
+                       BMenuField* menufield
+                               = 
dynamic_cast<BMenuField*>(FindView("filemenu"));
+                       if (menufield == NULL)
+                               return;
                        BMenu* menu = menufield->Menu();
 
                        HEventRow* row = 
(HEventRow*)fEventList->CurrentSelection();
@@ -199,8 +201,10 @@
                        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<BMenuField*>(FindView("filemenu"));
+                               if (menufield == NULL)
+                                       return; 
                                BMenu* menu = menufield->Menu();
 
                                // check audio file
@@ -267,7 +271,10 @@
                case M_EVENT_CHANGED:
                {
                        const char* path;
-                       BMenuField* menufield = cast_as(FindView("filemenu"), 
BMenuField);
+                       BMenuField* menufield
+                               = 
dynamic_cast<BMenuField*>(FindView("filemenu"));
+                       if (menufield == NULL)
+                               return;
                        BMenu* menu = menufield->Menu();
 
                        if (message->FindString("path", &path) == B_OK) {
@@ -308,7 +315,9 @@
 void
 HWindow::SetupMenuField()
 {
-       BMenuField* menufield = cast_as(FindView("filemenu"), BMenuField);
+       BMenuField* menufield = dynamic_cast<BMenuField*>(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 @@
 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<BMenuField*>(FindView("filemenu"));
+       BButton* button = dynamic_cast<BButton*>(FindView("play"));
+       BButton* stop = dynamic_cast<BButton*>(FindView("stop"));
 
-       if (menufield == NULL)
+       if (menufield == NULL || button == NULL || stop == NULL)
                return;
 
        if (row != NULL) {


Other related posts:

  • » [haiku-commits] r35600 - in haiku/trunk/src: apps/icon-o-matic/generic/property/view apps/mail preferences/sounds - alex