Fix initialization issues in libmyth

From: Erik Hovland <erik@hovland.org>


---

 mythtv/libs/libmyth/managedlist.cpp   |   25 ++--
 mythtv/libs/libmyth/mythdialogs.cpp   |   15 ++-
 mythtv/libs/libmyth/programinfo.cpp   |    2 
 mythtv/libs/libmyth/uilistbtntype.cpp |    8 +
 mythtv/libs/libmyth/uitypes.cpp       |  194 ++++++++++++++-------------------
 mythtv/libs/libmyth/uitypes.h         |   13 +-
 6 files changed, 120 insertions(+), 137 deletions(-)


diff --git a/mythtv/libs/libmyth/managedlist.cpp b/mythtv/libs/libmyth/managedlist.cpp
index 0015124..bfdf9b7 100644
--- a/mythtv/libs/libmyth/managedlist.cpp
+++ b/mythtv/libs/libmyth/managedlist.cpp
@@ -390,12 +390,15 @@ void ManagedListGroup::setParentList(ManagedList* _parent)
 // SelectManagedListItem
 //
 ///////////////////////////////////////////////////////////////////////////////
-SelectManagedListItem::SelectManagedListItem(
-    const QString& baseTxt, ManagedListGroup* pGroup, ManagedList* pList,
-    QObject* _parent, const char* _name)
-    : ManagedListGroup(baseTxt, pGroup, pList, _parent, _name)
+SelectManagedListItem::SelectManagedListItem(const QString& baseTxt,
+                                             ManagedListGroup* pGroup,
+                                             ManagedList* pList,
+                                             QObject* _parent,
+                                             const char* _name)
+    : ManagedListGroup(baseTxt, pGroup, pList, _parent, _name),
+      isSet(false), baseText(baseTxt),
+      lastItem(0)
 {
-    baseText = baseTxt;
     goBack->setText(QString("[ %1 ]").arg(QObject::tr("No Change")));
 }
 
@@ -588,14 +591,14 @@ void SelectManagedListItem::buttonSelected(ManagedListItem* itm)
 // ManagedList
 //
 ///////////////////////////////////////////////////////////////////////////////
-ManagedList::ManagedList(MythDialog* parent, const char* name) :
-    QObject(parent)
+ManagedList::ManagedList(MythDialog* parent, const char* name)
+    : QObject(parent),
+      curGroup(NULL), theme(NULL),
+      listSize(0),    containerName(""),
+      listName(""),   listRect(0, 0, 0, 0),
+      locked(false)
 {
     setObjectName(name);
-    listRect = QRect(0, 0, 0, 0);
-    theme = NULL;
-    curGroup = NULL;
-    locked = false;
 }
 
 ManagedListItem *ManagedList::getItem(const QString &itemName)
diff --git a/mythtv/libs/libmyth/mythdialogs.cpp b/mythtv/libs/libmyth/mythdialogs.cpp
index 9f84dc1..970296f 100644
--- a/mythtv/libs/libmyth/mythdialogs.cpp
+++ b/mythtv/libs/libmyth/mythdialogs.cpp
@@ -41,7 +41,12 @@ using namespace std;
  */
 
 MythDialog::MythDialog(MythMainWindow *parent, const char *name, bool setsize)
-    : QFrame(parent), rescode(kDialogCodeAccepted)
+    : QFrame(parent),
+      wmult(1.0),       hmult(1.0),
+      screenwidth(0),   screenheight(0),
+      xbase(0),         ybase(0),
+      m_parent(parent), rescode(kDialogCodeAccepted),
+      in_loop(false)
 {
     setObjectName(name);
     if (!parent)
@@ -50,7 +55,6 @@ MythDialog::MythDialog(MythMainWindow *parent, const char *name, bool setsize)
         return;
     }
 
-    in_loop = false;
     MythUIHelper *ui = GetMythUI();
 
     ui->GetScreenSettings(xbase, screenwidth, wmult,
@@ -72,7 +76,6 @@ MythDialog::MythDialog(MythMainWindow *parent, const char *name, bool setsize)
     setAutoFillBackground(true);
 
     parent->attach(this);
-    m_parent = parent;
 }
 
 MythDialog::~MythDialog()
@@ -1072,10 +1075,12 @@ MythThemedDialog::MythThemedDialog(MythMainWindow *parent,
 
 MythThemedDialog::MythThemedDialog(MythMainWindow *parent, const char* name,
                                    bool setsize)
-                : MythDialog(parent, name, setsize)
+    : MythDialog(parent, name, setsize),
+      widget_with_current_focus(NULL), my_background(),
+      my_foreground(),                 theme(NULL),
+      context(0),                      redrawRect(0, 0, 0, 0)
 {
     setNoErase();
-    theme = NULL;
 }
 
 bool MythThemedDialog::loadThemedWindow(QString window_name,
diff --git a/mythtv/libs/libmyth/programinfo.cpp b/mythtv/libs/libmyth/programinfo.cpp
index 7b03977..bfc6f56 100644
--- a/mythtv/libs/libmyth/programinfo.cpp
+++ b/mythtv/libs/libmyth/programinfo.cpp
@@ -58,6 +58,7 @@ ProgramInfo::ProgramInfo(void) :
     chanstr(""),
     chansign(""),
     channame(""),
+    m_videoWidth(0),
     m_videoHeight(0),
 
     recpriority(0),
@@ -149,6 +150,7 @@ ProgramInfo::ProgramInfo(const ProgramInfo &other) :
     chanstr(other.chanstr),
     chansign(other.chansign),
     channame(other.channame),
+    m_videoWidth(other.m_videoWidth),
     m_videoHeight(other.m_videoHeight),
 
     recpriority(other.recpriority),
diff --git a/mythtv/libs/libmyth/uilistbtntype.cpp b/mythtv/libs/libmyth/uilistbtntype.cpp
index fb7aeaa..85d4a5b 100644
--- a/mythtv/libs/libmyth/uilistbtntype.cpp
+++ b/mythtv/libs/libmyth/uilistbtntype.cpp
@@ -140,7 +140,7 @@ bool UIListGenericTree::movePositionUpDown(bool flag)
 UIListTreeType::UIListTreeType(const QString &name, const QRect &area,
                                const QRect &levelsize, int levelspacing,
                                int order)
-              : UIType(name)
+              : UIType(name, order, true)
 {
     m_totalarea = area;
     m_levelsize = levelsize;
@@ -156,7 +156,7 @@ UIListTreeType::UIListTreeType(const QString &name, const QRect &area,
 
     m_active = NULL;
     m_inactive = NULL;
-    takes_focus = true;
+//    takes_focus = true;
 
     SetItemRegColor(Qt::black,QColor(80,80,80),100);
     SetItemSelColor(QColor(82,202,56),QColor(52,152,56),255);
@@ -866,10 +866,9 @@ void UIListTreeType::looseFocus()
 
 UIListBtnType::UIListBtnType(const QString& name, const QRect& area,
                              int order, bool showArrow, bool showScrollArrows)
-             : UIType(name)
+             : UIType(name, order, true)
 {
     m_parentListTree   = NULL;
-    m_order            = order;
     m_rect             = area;
 
     m_showArrow        = showArrow;
@@ -877,7 +876,6 @@ UIListBtnType::UIListBtnType(const QString& name, const QRect& area,
 
     m_active           = false;
     m_visible          = true;
-    takes_focus        = true;
     m_showUpArrow      = false;
     m_showDnArrow      = false;
 
diff --git a/mythtv/libs/libmyth/uitypes.cpp b/mythtv/libs/libmyth/uitypes.cpp
index c4d1982..e3a2a8a 100644
--- a/mythtv/libs/libmyth/uitypes.cpp
+++ b/mythtv/libs/libmyth/uitypes.cpp
@@ -186,20 +186,16 @@ void LayerSet::SetDrawFontShadow(bool state)
 
 // **************************************************************
 
-UIType::UIType(const QString &name)
-       : QObject(NULL)
+UIType::UIType(const QString &name, int order, bool takes_focus, bool has_focus)
+    : QObject(NULL),
+      m_wmult(1.0),               m_hmult(1.0),
+      m_context(-1),              m_order(order),
+      m_debug(false),             m_name(name),
+      m_parent(NULL),             m_has_focus(has_focus),
+      m_takes_focus(takes_focus), screen_area(0, 0, 0, 0),
+      drawFontShadow(true),       hidden(false)
 {
     setObjectName(name);
-    m_parent = NULL;
-    m_name = name;
-    m_debug = false;
-    m_context = -1;
-    m_order = -1;
-    has_focus = false;
-    takes_focus = false;
-    screen_area = QRect(0,0,0,0);
-    drawFontShadow = true;
-    hidden = false;
 }
 
 void UIType::SetOrder(int order)
@@ -242,21 +238,21 @@ QString UIType::Name()
 
 bool UIType::takeFocus()
 {
-    if (takes_focus)
+    if (m_takes_focus)
     {
-        has_focus = true;
+        m_has_focus = true;
         refresh();
         emit takingFocus();
         return true;
     }
-    has_focus = false;
+    m_has_focus = false;
     return false;
 }
 
 void UIType::looseFocus()
 {
     emit loosingFocus();
-    has_focus = false;
+    m_has_focus = false;
     refresh();
 }
 
@@ -356,22 +352,20 @@ QString UIType::cutDown(const QString &data, QFont *testFont, bool multiline,
 // **************************************************************
 
 UIListType::UIListType(const QString &name, QRect area, int dorder)
-          : UIType(name)
+    : UIType(name, dorder, true),
+      m_selheight(0),    m_justification(0),
+      m_columns(0),      m_current(-1),
+      m_active(false),   m_pad(0),
+      m_count(0),        m_darrow(false),
+      m_uarrow(false),   m_showSelAlways(true),
+      m_fill_area(),     m_fill_color(),
+      m_fill_type(-1),   m_selection(),
+      m_downarrow(),     m_uparrow(),
+      m_leftarrow(),     m_rightarrow(),
+      m_selection_loc(), m_downarrow_loc(),
+      m_uparrow_loc(),   m_rightarrow_loc(),
+      m_leftarrow_loc(), m_area(area)
 {
-    m_name = name;
-    m_area = area;
-    m_order = dorder;
-    m_active = false;
-    m_columns = 0;
-    m_current = -1;
-    m_count = 0;
-    m_justification = 0;
-    m_uarrow = false;
-    m_darrow = false;
-    m_fill_type = -1;
-    m_showSelAlways = true;
-    has_focus = false;
-    takes_focus = true;
 }
 
 UIListType::~UIListType()
@@ -680,7 +674,7 @@ void UIListType::looseFocus()
 // *****************************************************************
 
 UIImageType::UIImageType(const QString &name, const QString &filename, int dorder, QPoint displaypos)
-           : UIType(name)
+           : UIType(name, dorder)
 {
     m_isvalid = false;
     m_flex = false;
@@ -1028,28 +1022,30 @@ void UIRepeatedImageType::refresh()
 // **************************************************************
 
 UIImageGridType::UIImageGridType(const QString &name, int order)
-    : UIType(name)
+    : UIType(name, order),
+      window(NULL),         rowCount(0),
+      columnCount(0),       itemCount(0),
+      currentItem(0),       borderWidth(0),
+      padding(0),           cellWidth(0),
+      cellHeight(0),        topRow(0),
+      lastRow(0),           lastColumn(0),
+      curColumn(0),         curRow(0),
+      displayRect(),        imageRect(),
+      checkRect(),          textPos(UIImageGridType::textPosBottom),
+      textHeight(20),
+      activeFont(NULL),     inactiveFont(NULL),
+      selectedFont(NULL),   cutdown(true),
+      showCheck(false),     showScrollArrows(false),
+      showSelected(false),  showUpArrow(false),
+      showDnArrow(false),
+      normalImage(""),      highlightedImage(""),
+      selectedImage(""),    defaultImage(""),
+      normalPixmap(NULL),   highlightedPixmap(NULL),
+      selectedPixmap(NULL), defaultPixmap(NULL),
+      allData(new QList<ImageGridItem*>)
 {
-    m_name = name;
-    m_order = order;
-
-    activeFont = inactiveFont = selectedFont = NULL;
-    window = NULL;
-    defaultPixmap = normalPixmap = selectedPixmap = highlightedPixmap = NULL;
-
-    topRow = rowCount = columnCount = itemCount = currentItem =
-            borderWidth = padding = cellWidth = cellHeight =
-            lastRow = lastColumn = curColumn = curRow = 0;
-
-    textPos = UIImageGridType::textPosBottom;
-    textHeight = 20;
-    cutdown = true;
     setJustification((Qt::AlignLeft | Qt::AlignVCenter));
     allowFocus(true);
-    showCheck = false;
-    showSelected = false;
-
-    allData = new QList<ImageGridItem*>;
 }
 
 UIImageGridType::~UIImageGridType(void)
@@ -1203,7 +1199,7 @@ void UIImageGridType::setJustification(int jst)
 
 bool UIImageGridType::handleKeyPress(QString action)
 {
-    if (!has_focus)
+    if (!m_has_focus)
         return false;
 
     if (action == "LEFT")
@@ -1469,7 +1465,7 @@ void UIImageGridType::drawText(QPainter *p, int curPos, int xpos, int ypos)
         p->drawRect(textRect);
     }
 
-    fontProp *font = has_focus ? activeFont : inactiveFont;
+    fontProp *font = m_has_focus ? activeFont : inactiveFont;
 
     if (item && item->selected && showSelected)
         font = selectedFont;
@@ -1603,10 +1599,9 @@ QSize UIImageGridType::getImageItemSize(void)
 UITextType::UITextType(const QString &name, fontProp *font,
                        const QString &text, int dorder, QRect displayrect,
                        QRect altdisplayrect)
-           : UIType(name)
+    : UIType(name, dorder)
 {
 
-    m_name = name;
     if (text.length())
         m_message = text;
     else
@@ -1618,7 +1613,6 @@ UITextType::UITextType(const QString &name, fontProp *font,
     m_origdisplaysize = displayrect;
     m_altdisplaysize = altdisplayrect;
     m_cutdown = true;
-    m_order = dorder;
     m_justification = (Qt::AlignLeft | Qt::AlignTop);
 }
 
@@ -1731,14 +1725,12 @@ void UITextType::calculateScreenArea()
 
 UIRemoteEditType::UIRemoteEditType(const QString &name, fontProp *font,
                        const QString &text, int dorder, QRect displayrect)
-           : UIType(name)
+           : UIType(name, dorder, true)
 {
     m_font = font;
     m_text = text;
     m_displaysize = displayrect;
-    m_order = dorder;
     edit = NULL;
-    takes_focus = true;
 }
 
 void UIRemoteEditType::createEdit(MythThemedDialog* parent)
@@ -1896,13 +1888,12 @@ void UIRemoteEditType::editorChanged(QString value)
 // ******************************************************************
 
 UIStatusBarType::UIStatusBarType(QString &name, QPoint loc, int dorder)
-               : UIType(name)
+    : UIType(name, dorder),
+      m_used(0),        m_total(100),
+      m_fillerSpace(0), m_container(),
+      m_filler(),       m_location(loc),
+      m_orientation(0)
 {
-    m_location = loc;
-    m_order = dorder;
-    m_orientation = 0;
-    m_used = 0;
-    m_total = 100;
 }
 
 UIStatusBarType::~UIStatusBarType()
@@ -1991,37 +1982,26 @@ void UIStatusBarType::setOrientation(int x)
 // *********************************************************************
 
 UIManagedTreeListType::UIManagedTreeListType(const QString & name)
-                     : UIType(name)
+    : UIType(name),
+      area(),                   bins(0),
+      active_bin(0),            my_tree_data(NULL),
+      current_node(NULL),       active_parent(NULL),
+      active_node(NULL),        tree_order(-1),
+      visual_order(-1),         iconAttr(-1),
+      selectPadding(0),         selectScale(false),
+      m_justification(Qt::AlignLeft | Qt::AlignVCenter),
+      highlight_image(),        up_arrow_image(),
+      down_arrow_image(),       left_arrow_image(),
+      right_arrow_image(),      show_whole_tree(false),
+      scrambled_parents(false), color_selectables(false),
+      selectPoint(0, 0),        upArrowOffset(0, 0),
+      downArrowOffset(0, 0),    leftArrowOffset(0, 0),
+      rightArrowOffset(0, 0),   incSearch(""),
+      bIncSearchContains(false)
 {
-    bins = 0;
     bin_corners.clear();
     screen_corners.clear();
     route_to_active.clear();
-    my_tree_data = NULL;
-    current_node = NULL;
-    active_node = NULL;
-    active_parent = NULL;
-    m_justification = (Qt::AlignLeft | Qt::AlignVCenter);
-    active_bin = 0;
-    tree_order = -1;
-    visual_order = -1;
-    iconAttr = -1;
-    show_whole_tree = false;
-    scrambled_parents = false;
-    color_selectables = false;
-    selectPadding = 0;
-    selectScale = false;
-    selectPoint.setX(0);
-    selectPoint.setY(0);
-    upArrowOffset.setX(0);
-    upArrowOffset.setY(0);
-    downArrowOffset.setX(0);
-    downArrowOffset.setY(0);
-    leftArrowOffset.setX(0);
-    leftArrowOffset.setY(0);
-    rightArrowOffset.setX(0);
-    rightArrowOffset.setY(0);
-    incSearch = "";
 }
 
 UIManagedTreeListType::~UIManagedTreeListType()
@@ -3464,14 +3444,13 @@ void UIManagedTreeListType::calculateScreenArea()
 // ********************************************************************
 
 UIPushButtonType::UIPushButtonType(const QString &name, QPixmap on, QPixmap off, QPixmap pushed, QPixmap pushedon)
-                     : UIType(name)
+    : UIType(name, -1, true)
 {
     on_pixmap = on;
     off_pixmap = off;
     pushed_pixmap = pushed;
     pushedon_pixmap = pushedon;
     currently_pushed = false;
-    takes_focus = true;
     m_lockOn = false;
     connect(&push_timer, SIGNAL(timeout()), this, SLOT(unPush()));
 }
@@ -3498,7 +3477,7 @@ void UIPushButtonType::Draw(QPainter *p, int drawlayer, int context)
 
     if (currently_pushed)
     {
-        if (has_focus && !pushedon_pixmap.isNull())
+        if (m_has_focus && !pushedon_pixmap.isNull())
         {
             p->drawPixmap(m_displaypos.x(), m_displaypos.y(), pushedon_pixmap);
         }
@@ -3509,7 +3488,7 @@ void UIPushButtonType::Draw(QPainter *p, int drawlayer, int context)
     }
     else
     {
-        if (has_focus)
+        if (m_has_focus)
         {
             p->drawPixmap(m_displaypos.x(), m_displaypos.y(), on_pixmap);
         }
@@ -3598,14 +3577,13 @@ void UIPushButtonType::calculateScreenArea()
 // ********************************************************************
 
 UITextButtonType::UITextButtonType(const QString &name, QPixmap on, QPixmap off, QPixmap pushed)
-                     : UIType(name)
+    : UIType(name, -1, true)
 {
     on_pixmap = on;
     off_pixmap = off;
     pushed_pixmap = pushed;
     m_text = "";
     currently_pushed = false;
-    takes_focus = true;
     connect(&push_timer, SIGNAL(timeout()), this, SLOT(unPush()));
 }
 
@@ -3635,7 +3613,7 @@ void UITextButtonType::Draw(QPainter *p, int drawlayer, int context)
     }
     else
     {
-        if (has_focus)
+        if (m_has_focus)
         {
             p->drawPixmap(m_displaypos.x(), m_displaypos.y(), on_pixmap);
         }
@@ -3718,7 +3696,7 @@ void UITextButtonType::calculateScreenArea()
 UICheckBoxType::UICheckBoxType(const QString &name,
                                QPixmap checkedp, QPixmap uncheckedp,
                                QPixmap checked_highp, QPixmap unchecked_highp)
-               :UIType(name)
+    : UIType(name, -1, true)
 {
     checked_pixmap = checkedp;
     unchecked_pixmap = uncheckedp;
@@ -3726,7 +3704,6 @@ UICheckBoxType::UICheckBoxType(const QString &name,
     unchecked_pixmap_high = unchecked_highp;
     checked = false;
     label = "";
-    takes_focus = true;
 }
 
 void UICheckBoxType::Draw(QPainter *p, int drawlayer, int context)
@@ -3747,7 +3724,7 @@ void UICheckBoxType::Draw(QPainter *p, int drawlayer, int context)
         return;
     }
 
-    if (has_focus)
+    if (m_has_focus)
     {
         if (checked)
         {
@@ -3864,7 +3841,7 @@ void UISelectorType::Draw(QPainter *p, int drawlayer, int context)
     }
     else
     {
-        if (has_focus)
+        if (m_has_focus)
         {
             p->drawPixmap(m_displaypos.x(), m_displaypos.y(), on_pixmap);
         }
@@ -4007,7 +3984,7 @@ void UIBlackHoleType::calculateScreenArea()
 // ********************************************************************
 
 UIKeyType::UIKeyType(const QString &name)
-         : UIType(name)
+         : UIType(name, -1, true)
 {
     m_normalImg = m_focusedImg = m_downImg = m_downFocusedImg = NULL;
     m_normalFont = m_focusedFont = m_downFont = m_downFocusedFont = NULL;
@@ -4018,8 +3995,6 @@ UIKeyType::UIKeyType(const QString &name)
     m_bShift = false;
     m_bAlt = false;
     m_bToggle = false;
-
-    takes_focus = true;
     connect(&m_pushTimer, SIGNAL(timeout()), this, SLOT(unPush()));
 }
 
@@ -4038,7 +4013,7 @@ void UIKeyType::Draw(QPainter *dr, int drawlayer, int context)
             // draw the button image
             if (!m_bDown)
             {
-                if (!has_focus)
+                if (!m_has_focus)
                 {
                     dr->drawPixmap(m_pos.x(), m_pos.y(), *m_normalImg);
                     tempFont = m_normalFont;
@@ -4051,7 +4026,7 @@ void UIKeyType::Draw(QPainter *dr, int drawlayer, int context)
             }
             else
             {
-                if (!has_focus)
+                if (!m_has_focus)
                 {
                     dr->drawPixmap(m_pos.x(), m_pos.y(), *m_downImg);
                     tempFont = m_downFont;
@@ -4327,9 +4302,8 @@ const QString comps[numcomps][3] = {
 };
 
 UIKeyboardType::UIKeyboardType(const QString &name, int order)
-                    : UIType(name)
+    : UIType(name, order)
 {
-    m_order = order;
     m_container = NULL;
     m_parentEdit = NULL;
     m_parentDialog = NULL;
diff --git a/mythtv/libs/libmyth/uitypes.h b/mythtv/libs/libmyth/uitypes.h
index c373cc3..d9c1833 100644
--- a/mythtv/libs/libmyth/uitypes.h
+++ b/mythtv/libs/libmyth/uitypes.h
@@ -85,7 +85,8 @@ class MPUBLIC UIType : public QObject
   Q_OBJECT
 
   public:
-    UIType(const QString &name);
+    UIType(const QString &name, int order = -1, bool takes_focus = false,
+           bool has_focus = false);
     virtual ~UIType();
 
     void SetOrder(int order);
@@ -94,12 +95,12 @@ class MPUBLIC UIType : public QObject
     void SetContext(int con) { m_context = con;}
     int  GetContext(){return m_context;}
     void SetDebug(bool db) { m_debug = db; }
-    void allowFocus(bool yes_or_no){takes_focus = yes_or_no;}
+    void allowFocus(bool yes_or_no){m_takes_focus = yes_or_no;}
     void SetDrawFontShadow(bool state) { drawFontShadow = state; }
     QString Name();
 
 
-    bool    canTakeFocus(){ return takes_focus;}
+    bool    canTakeFocus(){ return m_takes_focus;}
     int     getOrder(){return m_order;}
     virtual void Draw(QPainter *, int, int);
     virtual void DrawRegion(QPainter *, QRect &, int, int);
@@ -111,7 +112,7 @@ class MPUBLIC UIType : public QObject
 
     bool    isShown(){return !hidden;}
     bool    isHidden(){return hidden;}
-    bool    isFocused(){return has_focus;}
+    bool    isFocused(){return m_has_focus;}
 
   public slots:
 
@@ -145,8 +146,8 @@ class MPUBLIC UIType : public QObject
     bool     m_debug;
     QString  m_name;
     LayerSet *m_parent;
-    bool     has_focus;
-    bool     takes_focus;
+    bool     m_has_focus;
+    bool     m_takes_focus;
     QRect    screen_area;   // The area, in real screen coordinates
     bool     drawFontShadow;
     bool     hidden;        // Is this "widget" seen or hidden ?
