QBrush: enable -Wswitch in strategic places

Since we rely on the brush style to distinguish between the three
different QBrushData subclasses, we should grab all the help we need
to not mess up, so replace default case labels with the expanded list
of brush styles, so that -Wswitch shall always prompt those adding new
styles to add them to the the correct branch of each switch, rather
than having them treated as Basic by default.

Coverity-Id: 11772
Coverity-Id: 218724
Change-Id: Id6280695a4d9cb8af6dedd283aa4cc4be73806fa
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Marc Mutz 2016-10-06 09:51:32 +02:00 committed by Marc Mutz
parent 13965b020e
commit e3a4cf013c

View File

@ -227,7 +227,21 @@ static void deleteData(QBrushData *d)
case Qt::ConicalGradientPattern: case Qt::ConicalGradientPattern:
delete static_cast<QGradientBrushData*>(d); delete static_cast<QGradientBrushData*>(d);
break; break;
default: case Qt::NoBrush:
case Qt::SolidPattern:
case Qt::Dense1Pattern:
case Qt::Dense2Pattern:
case Qt::Dense3Pattern:
case Qt::Dense4Pattern:
case Qt::Dense5Pattern:
case Qt::Dense6Pattern:
case Qt::Dense7Pattern:
case Qt::HorPattern:
case Qt::VerPattern:
case Qt::CrossPattern:
case Qt::BDiagPattern:
case Qt::FDiagPattern:
case Qt::DiagCrossPattern:
delete static_cast<QBasicBrushData*>(d); delete static_cast<QBasicBrushData*>(d);
break; break;
} }
@ -381,7 +395,20 @@ void QBrush::init(const QColor &color, Qt::BrushStyle style)
case Qt::ConicalGradientPattern: case Qt::ConicalGradientPattern:
d.reset(new QGradientBrushData); d.reset(new QGradientBrushData);
break; break;
default: case Qt::SolidPattern:
case Qt::Dense1Pattern:
case Qt::Dense2Pattern:
case Qt::Dense3Pattern:
case Qt::Dense4Pattern:
case Qt::Dense5Pattern:
case Qt::Dense6Pattern:
case Qt::Dense7Pattern:
case Qt::HorPattern:
case Qt::VerPattern:
case Qt::CrossPattern:
case Qt::BDiagPattern:
case Qt::FDiagPattern:
case Qt::DiagCrossPattern:
d.reset(new QBasicBrushData); d.reset(new QBasicBrushData);
break; break;
} }
@ -590,7 +617,21 @@ void QBrush::detach(Qt::BrushStyle newStyle)
x.reset(gbd); x.reset(gbd);
break; break;
} }
default: case Qt::NoBrush:
case Qt::SolidPattern:
case Qt::Dense1Pattern:
case Qt::Dense2Pattern:
case Qt::Dense3Pattern:
case Qt::Dense4Pattern:
case Qt::Dense5Pattern:
case Qt::Dense6Pattern:
case Qt::Dense7Pattern:
case Qt::HorPattern:
case Qt::VerPattern:
case Qt::CrossPattern:
case Qt::BDiagPattern:
case Qt::FDiagPattern:
case Qt::DiagCrossPattern:
x.reset(new QBasicBrushData); x.reset(new QBasicBrushData);
break; break;
} }