Permalink
Browse files

Fix a few 'Unchecked dynamic_cast' warnings from Coverity in libmythu…

…i. Most of these could safely be switched to static_cast because they are not expected to fail.
  • Loading branch information...
stuartm committed May 10, 2012
1 parent 97bbc95 commit 943bfe92e9cdbd3d9d264a124927ef914aad0304
@@ -2081,7 +2081,7 @@ bool MythMainWindow::eventFilter(QObject *, QEvent *e)
d->gestureTimer->stop();
d->gestureTimer->start(GESTURE_TIMEOUT);
- d->gesture.record(dynamic_cast<QMouseEvent*>(e)->pos());
+ d->gesture.record(static_cast<QMouseEvent*>(e)->pos());
return true;
}
break;
@@ -2090,7 +2090,7 @@ bool MythMainWindow::eventFilter(QObject *, QEvent *e)
{
ResetIdleTimer();
ShowMouseCursor(true);
- QWheelEvent* qmw = dynamic_cast<QWheelEvent*>(e);
+ QWheelEvent* qmw = static_cast<QWheelEvent*>(e);
int delta = qmw->delta();
if (delta>0)
{
@@ -614,6 +614,8 @@ bool MythUIButtonList::DistributeRow(int &first_button, int &last_button,
realButton = m_ButtonList[buttonIdx];
buttonstate = dynamic_cast<MythUIGroup *>
(realButton->GetCurrentState());
+ if (!buttonstate)
+ break;
width = minButtonWidth(buttonstate->GetArea());
if ((*col_widths)[col_idx] < width)
@@ -1182,6 +1184,9 @@ bool MythUIButtonList::DistributeButtons(void)
realButton = m_ButtonList[buttonIdx];
buttonstate = dynamic_cast<MythUIGroup *>
(realButton->GetCurrentState());
+ if (!buttonstate)
+ break; // Not continue
+
MythRect area = buttonstate->GetArea();
// Center button within width of column
@@ -1876,7 +1881,7 @@ int MythUIButtonList::PageDown(void)
buttonstate = dynamic_cast<MythUIGroup *>
(realButton->GetCurrentState());
- if (buttonstate == NULL)
+ if (!buttonstate)
{
LOG(VB_GENERAL, LOG_ERR,
"PageDown: Failed to query buttonlist state");
@@ -1890,7 +1895,8 @@ int MythUIButtonList::PageDown(void)
buttonItem->SetToRealButton(realButton, false);
buttonstate = dynamic_cast<MythUIGroup *>
(realButton->GetCurrentState());
- total += m_itemHorizSpacing + buttonstate->GetArea().height();
+ if (buttonstate)
+ total += m_itemHorizSpacing + buttonstate->GetArea().height();
}
return num_items - 1;
@@ -2503,7 +2509,7 @@ void MythUIButtonList::customEvent(QEvent *event)
if (event->type() == NextButtonListPageEvent::kEventType)
{
NextButtonListPageEvent *npe =
- dynamic_cast<NextButtonListPageEvent*>(event);
+ static_cast<NextButtonListPageEvent*>(event);
int cur = npe->m_start;
for (; cur < npe->m_start + npe->m_pageSize && cur < GetCount(); ++cur)
{
@@ -1502,7 +1502,7 @@ void MythUIImage::customEvent(QEvent *event)
QString filename;
bool aborted;
- ImageLoadEvent *le = dynamic_cast<ImageLoadEvent *>(event);
+ ImageLoadEvent *le = static_cast<ImageLoadEvent *>(event);
if (le->GetParent() != this)
return;
@@ -341,7 +341,7 @@ void MythUIStateType::RecalculateArea(bool recurse)
{
if (objectName().startsWith("buttonlist button"))
{
- MythUIButtonList *list = dynamic_cast<MythUIButtonList *>(m_Parent);
+ MythUIButtonList *list = static_cast<MythUIButtonList *>(m_Parent);
m_ParentArea = list->GetButtonArea();
}
else

0 comments on commit 943bfe9

Please sign in to comment.