Ticket #5502: libs_libmythui-check-dyn_cast-ticket-5502.patch

File libs_libmythui-check-dyn_cast-ticket-5502.patch, 2.2 KB (added by Erik Hovland <erik@…>, 11 years ago)

Latest version of the dyn cast patch

  • mythtv/libs/libmythui/mythuibutton.cpp

    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 
    41#include "mythuibutton.h"
    52#include "mythmainwindow.h"
     3#include "mythverbose.h"
     4#include <iostream>
     5using namespace std;
    66
    77MythUIButton::MythUIButton(MythUIType *parent, const QString &name, bool doInit)
    88            : MythUIType(parent, name)
    void MythUIButton::CopyFrom(MythUIType *base) 
    390390    MythUIButton *button = dynamic_cast<MythUIButton *>(base);
    391391    if (!button)
    392392    {
    393         cerr << "ERROR, bad parsing" << endl;
     393        VERBOSE(VB_IMPORTANT,
     394                "MythUIButton::CopyFrom: Dynamic cast of base failed");
    394395        return;
    395396    }
    396397
    void MythUIButton::CopyFrom(MythUIType *base) 
    414415                    (GetChild("buttonimage"));
    415416    m_ArrowImage = dynamic_cast<MythUIImage *>
    416417                    (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    }
    417425
    418426    m_CheckImage->SetVisible(false);
    419427    m_ButtonImage->SetVisible(false);
  • mythtv/libs/libmythui/mythuibuttonlist.cpp

    diff --git a/mythtv/libs/libmythui/mythuibuttonlist.cpp b/mythtv/libs/libmythui/mythuibuttonlist.cpp
    index b2f5dfb..db15442 100644
    a b void MythUIButtonList::Init() 
    690690    {
    691691        QString name = QString("buttonlist button %1").arg(i);
    692692        MythUIStateType *button = new MythUIStateType(this, name);
    693         button->CopyFrom(buttontemplate);
     693        if (buttontemplate)
     694            button->CopyFrom(buttontemplate);
    694695
    695696        if (col > m_columns)
    696697        {