Skip to content

Commit

Permalink
Fix a few 'Unchecked dynamic_cast' warnings from Coverity in libmythu…
Browse files Browse the repository at this point in the history
…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 943bfe9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions mythtv/libs/libmythui/mythmainwindow.cpp
Expand Up @@ -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;
Expand All @@ -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)
{
Expand Down
12 changes: 9 additions & 3 deletions mythtv/libs/libmythui/mythuibuttonlist.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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");
Expand All @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythui/mythuiimage.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythui/mythuistatetype.cpp
Expand Up @@ -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
Expand Down

0 comments on commit 943bfe9

Please sign in to comment.