Author: zooey Date: 2010-08-17 16:56:51 +0200 (Tue, 17 Aug 2010) New Revision: 38188 Changeset: http://dev.haiku-os.org/changeset/38188 Modified: haiku/trunk/build/jam/BuildSetup haiku/trunk/src/preferences/notifications/IconItem.cpp haiku/trunk/src/preferences/notifications/IconRule.cpp haiku/trunk/src/preferences/notifications/IconRule.h haiku/trunk/src/preferences/notifications/NotificationsView.cpp haiku/trunk/src/preferences/notifications/PrefletView.cpp Log: Fixes to Notifications preflet * CID-1501: protect against dynamic_cast potentially returning NULL * additional style fixes * fixed all warnings and enabled -Werror Modified: haiku/trunk/build/jam/BuildSetup =================================================================== --- haiku/trunk/build/jam/BuildSetup 2010-08-17 14:42:14 UTC (rev 38187) +++ haiku/trunk/build/jam/BuildSetup 2010-08-17 14:56:51 UTC (rev 38188) @@ -1406,7 +1406,7 @@ 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 ; Modified: haiku/trunk/src/preferences/notifications/IconItem.cpp =================================================================== --- haiku/trunk/src/preferences/notifications/IconItem.cpp 2010-08-17 14:42:14 UTC (rev 38187) +++ haiku/trunk/src/preferences/notifications/IconItem.cpp 2010-08-17 14:56:51 UTC (rev 38188) @@ -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) : + fLabel(label), fIcon(icon), - fLabel(label), fSelected(false), fOwner(owner) { Modified: haiku/trunk/src/preferences/notifications/IconRule.cpp =================================================================== --- haiku/trunk/src/preferences/notifications/IconRule.cpp 2010-08-17 14:42:14 UTC (rev 38187) +++ haiku/trunk/src/preferences/notifications/IconRule.cpp 2010-08-17 14:56:51 UTC (rev 38188) @@ -146,7 +146,7 @@ } -int32 +void BIconRule::AddIcon(const char* label, const BBitmap* icon) { BIconItem* item = new BIconItem(this, label, (BBitmap*)icon); Modified: haiku/trunk/src/preferences/notifications/IconRule.h =================================================================== --- haiku/trunk/src/preferences/notifications/IconRule.h 2010-08-17 14:42:14 UTC (rev 38187) +++ haiku/trunk/src/preferences/notifications/IconRule.h 2010-08-17 14:56:51 UTC (rev 38188) @@ -27,7 +27,7 @@ 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(); Modified: haiku/trunk/src/preferences/notifications/NotificationsView.cpp =================================================================== --- haiku/trunk/src/preferences/notifications/NotificationsView.cpp 2010-08-17 14:42:14 UTC (rev 38187) +++ haiku/trunk/src/preferences/notifications/NotificationsView.cpp 2010-08-17 14:56:51 UTC (rev 38188) @@ -140,17 +140,22 @@ 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: Modified: haiku/trunk/src/preferences/notifications/PrefletView.cpp =================================================================== --- haiku/trunk/src/preferences/notifications/PrefletView.cpp 2010-08-17 14:42:14 UTC (rev 38187) +++ haiku/trunk/src/preferences/notifications/PrefletView.cpp 2010-08-17 14:56:51 UTC (rev 38188) @@ -32,9 +32,9 @@ // 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);