Skip to content

Commit

Permalink
Simplify the CC708CharacterAttribute constructor.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
stichnot committed Jun 11, 2013
1 parent e8aff2f commit d7294fc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/cc708window.cpp
Expand Up @@ -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)
Expand Down
15 changes: 6 additions & 9 deletions mythtv/libs/libmythtv/cc708window.h
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit d7294fc

Please sign in to comment.