dynamic_cast should be checked
From: Erik Hovland <erik@hovland.org>
---
mythtv/libs/libmythui/mythuibutton.cpp | 16 ++++++++++++----
mythtv/libs/libmythui/mythuibuttonlist.cpp | 3 ++-
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/mythtv/libs/libmythui/mythuibutton.cpp b/mythtv/libs/libmythui/mythuibutton.cpp
index dd274f9..34892e4 100644
|
a
|
b
|
|
| 1 | | #include <iostream> |
| 2 | | using namespace std; |
| 3 | | |
| 4 | 1 | #include "mythuibutton.h" |
| 5 | 2 | #include "mythmainwindow.h" |
| | 3 | #include "mythverbose.h" |
| | 4 | #include <iostream> |
| | 5 | using namespace std; |
| 6 | 6 | |
| 7 | 7 | MythUIButton::MythUIButton(MythUIType *parent, const QString &name, bool doInit) |
| 8 | 8 | : MythUIType(parent, name) |
| … |
… |
void MythUIButton::CopyFrom(MythUIType *base)
|
| 390 | 390 | MythUIButton *button = dynamic_cast<MythUIButton *>(base); |
| 391 | 391 | if (!button) |
| 392 | 392 | { |
| 393 | | cerr << "ERROR, bad parsing" << endl; |
| | 393 | VERBOSE(VB_IMPORTANT, |
| | 394 | "MythUIButton::CopyFrom: Dynamic cast of base failed"); |
| 394 | 395 | return; |
| 395 | 396 | } |
| 396 | 397 | |
| … |
… |
void MythUIButton::CopyFrom(MythUIType *base)
|
| 414 | 415 | (GetChild("buttonimage")); |
| 415 | 416 | m_ArrowImage = dynamic_cast<MythUIImage *> |
| 416 | 417 | (GetChild("arrowimage")); |
| | 418 | if (m_BackgroundImage || !m_CheckImage || !m_Text || !m_ButtonImage || |
| | 419 | !m_ArrowImage) |
| | 420 | { |
| | 421 | VERBOSE(VB_IMPORTANT, |
| | 422 | "MythUIButton::CopyFrom: Dynamic cast of a child failed"); |
| | 423 | return; |
| | 424 | } |
| 417 | 425 | |
| 418 | 426 | m_CheckImage->SetVisible(false); |
| 419 | 427 | m_ButtonImage->SetVisible(false); |
diff --git a/mythtv/libs/libmythui/mythuibuttonlist.cpp b/mythtv/libs/libmythui/mythuibuttonlist.cpp
index b2f5dfb..db15442 100644
|
a
|
b
|
void MythUIButtonList::Init()
|
| 690 | 690 | { |
| 691 | 691 | QString name = QString("buttonlist button %1").arg(i); |
| 692 | 692 | MythUIStateType *button = new MythUIStateType(this, name); |
| 693 | | button->CopyFrom(buttontemplate); |
| | 693 | if (buttontemplate) |
| | 694 | button->CopyFrom(buttontemplate); |
| 694 | 695 | |
| 695 | 696 | if (col > m_columns) |
| 696 | 697 | { |