Fixes to Notifications preflet

* CID-1501: protect against dynamic_cast potentially returning NULL
* additional style fixes
* fixed all warnings and enabled -Werror

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38188 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Tappe 2010-08-17 14:56:51 +00:00
parent 6137279338
commit 2655efc395
6 changed files with 23 additions and 18 deletions

View File

@ -1406,7 +1406,7 @@ if $(HAIKU_NO_WERROR) != 1 {
EnableWerror src preferences media ;
EnableWerror src preferences mouse ;
EnableWerror src preferences network ;
# EnableWerror src preferences notifications ;
EnableWerror src preferences notifications ;
EnableWerror src preferences opengl ;
EnableWerror src preferences print ;
EnableWerror src preferences screen ;

View File

@ -17,10 +17,10 @@
const int32 kEdgeOffset = 4;
BIconItem::BIconItem(BView* owner, const char* label, BBitmap* icon)
BIconItem::BIconItem(BView* owner, const char* label, BBitmap* icon)
:
fIcon(icon),
fLabel(label),
fIcon(icon),
fSelected(false),
fOwner(owner)
{

View File

@ -146,7 +146,7 @@ BIconRule::SetSelectionMessage(BMessage* message)
}
int32
void
BIconRule::AddIcon(const char* label, const BBitmap* icon)
{
BIconItem* item = new BIconItem(this, label, (BBitmap*)icon);

View File

@ -27,7 +27,7 @@ public:
BMessage* SelectionMessage() const;
void SetSelectionMessage(BMessage* message);
int32 AddIcon(const char* label, const BBitmap* icon);
void AddIcon(const char* label, const BBitmap* icon);
void RemoveIconAt(int32 index);
void RemoveAllIcons();

View File

@ -140,17 +140,22 @@ void
NotificationsView::MessageReceived(BMessage* msg)
{
switch (msg->what) {
case kApplicationSelected: {
BRow *row = fApplications->CurrentSelection();
if (row == NULL)
return;
BStringField* appname =
dynamic_cast<BStringField*>(row->GetField(kAppIndex));
case kApplicationSelected:
{
BRow* row = fApplications->CurrentSelection();
if (row == NULL)
return;
BStringField* appName
= dynamic_cast<BStringField*>(row->GetField(kAppIndex));
if (appName == NULL)
break;
appusage_t::iterator it = fAppFilters.find(appname->String());
if (it != fAppFilters.end())
_Populate(it->second);
} break;
appusage_t::iterator it = fAppFilters.find(appName->String());
if (it != fAppFilters.end())
_Populate(it->second);
break;
}
case kNotificationSelected:
break;
default:

View File

@ -32,9 +32,9 @@ PrefletView::PrefletView(SettingsHost* host)
// Page selector
fRule = new BIconRule("icon_rule");
fRule->SetSelectionMessage(new BMessage(kPageSelected));
(void)fRule->AddIcon(_T("General"), NULL);
(void)fRule->AddIcon(_T("Display"), NULL);
//(void)fRule->AddIcon(_T("Notifications"), NULL);
fRule->AddIcon(_T("General"), NULL);
fRule->AddIcon(_T("Display"), NULL);
//fRule->AddIcon(_T("Notifications"), NULL);
// View for card layout
fPagesView = new BView("pages", B_WILL_DRAW);