From d7294fc7157632f9e909e86fd033e8e8c5174a8e Mon Sep 17 00:00:00 2001 From: Jim Stichnoth Date: Tue, 11 Jun 2013 06:42:30 -0700 Subject: [PATCH] Simplify the CC708CharacterAttribute constructor. Fixes Coverity 700905 by explicitly initializing all fields of CC708CharacterAttribute in its constructor. Originally, most fields were left uninitialized, presumably for performance reasons, but there does not appear to be a performance difference even on an ION frontend. --- mythtv/libs/libmythtv/cc708window.cpp | 2 +- mythtv/libs/libmythtv/cc708window.h | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/mythtv/libs/libmythtv/cc708window.cpp b/mythtv/libs/libmythtv/cc708window.cpp index 6ec6c4fb66b..ac27a54c5ce 100644 --- a/mythtv/libs/libmythtv/cc708window.cpp +++ b/mythtv/libs/libmythtv/cc708window.cpp @@ -548,7 +548,7 @@ void CC708Pen::SetPenStyle(uint style) attr.bg_opacity = (style<6) ? k708AttrOpacitySolid : k708AttrOpacityTransparent; attr.edge_color = k708AttrColorBlack; - attr.override_fg_color = false; + attr.actual_fg_color = QColor(); } CC708Character::CC708Character(const CC708Window &win) diff --git a/mythtv/libs/libmythtv/cc708window.h b/mythtv/libs/libmythtv/cc708window.h index 84894677004..dc4cfe4991c 100644 --- a/mythtv/libs/libmythtv/cc708window.h +++ b/mythtv/libs/libmythtv/cc708window.h @@ -69,8 +69,6 @@ extern const uint k708AttrOpacityTransparent; class CC708CharacterAttribute { public: - // Note this is intenionally not initialized in the constructor. - uint pen_size; uint offset; uint text_tag; @@ -86,11 +84,12 @@ class CC708CharacterAttribute uint bg_opacity; uint edge_color; - bool override_fg_color; // for a color not in the 6-bit palette - QColor actual_fg_color; + QColor actual_fg_color; // if !isValid(), then convert fg_color - CC708CharacterAttribute(bool isItalic, bool isBold, bool isUnderline, - QColor fgColor) : + CC708CharacterAttribute(bool isItalic = false, + bool isBold = false, + bool isUnderline = false, + QColor fgColor = QColor()) : pen_size(k708AttrSizeStandard), offset(k708AttrOffsetNormal), text_tag(0), // "dialog", ignored @@ -104,11 +103,9 @@ class CC708CharacterAttribute bg_color(k708AttrColorBlack), bg_opacity(k708AttrOpacitySolid), edge_color(k708AttrColorBlack), - override_fg_color(true), actual_fg_color(fgColor) { } - CC708CharacterAttribute(void) : override_fg_color(false) {} // remove this uint FontIndex(void) const @@ -119,7 +116,7 @@ class CC708CharacterAttribute static QColor ConvertToQColor(uint eia708color); QColor GetFGColor(void) const { - QColor fg = (override_fg_color ? + QColor fg = (actual_fg_color.isValid() ? actual_fg_color : ConvertToQColor(fg_color)); fg.setAlpha(GetFGAlpha()); return fg;