ModelEditor: Introduce QMT_ASSERT

This change shall solve a lot of Coverity findings

Change-Id: I1e699f7363426e9b6008fc77d3f498fe3d968b4f
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Jochen Becher
2017-07-09 11:49:13 +02:00
parent 8ccdbe1944
commit 05f7b92f0a
49 changed files with 360 additions and 362 deletions

View File

@@ -47,13 +47,13 @@ PaletteBox::~PaletteBox()
QBrush PaletteBox::brush(int index) const
{
QMT_CHECK(index >= 0 && index <= m_brushes.size());
QMT_ASSERT(index >= 0 && index <= m_brushes.size(), return QBrush());
return m_brushes.at(index);
}
void PaletteBox::setBrush(int index, const QBrush &brush)
{
QMT_CHECK(index >= 0 && index <= m_brushes.size());
QMT_ASSERT(index >= 0 && index <= m_brushes.size(), return);
if (m_brushes[index] != brush) {
m_brushes[index] = brush;
update();
@@ -62,13 +62,13 @@ void PaletteBox::setBrush(int index, const QBrush &brush)
QPen PaletteBox::linePen(int index) const
{
QMT_CHECK(index >= 0 && index <= m_pens.size());
QMT_ASSERT(index >= 0 && index <= m_pens.size(), return QPen());
return m_pens.at(index);
}
void PaletteBox::setLinePen(int index, const QPen &pen)
{
QMT_CHECK(index >= 0 && index <= m_pens.size());
QMT_ASSERT(index >= 0 && index <= m_pens.size(), return);
if (m_pens[index] != pen) {
m_pens[index] = pen;
update();
@@ -125,7 +125,7 @@ void PaletteBox::mousePressEvent(QMouseEvent *event)
qreal w = static_cast<qreal>(width()) / static_cast<qreal>(m_brushes.size());
int i = static_cast<int>((event->x() / w));
QMT_CHECK(i >= 0 && i < m_brushes.size());
QMT_ASSERT(i >= 0 && i < m_brushes.size(), return);
setCurrentIndex(i);
if (m_currentIndex >= 0 && m_currentIndex < m_brushes.size())
emit activated(m_currentIndex);