summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSarah Jane Smith <sez@storybridge.org>2011-04-10 18:46:58 +1000
committerSarah Jane Smith <sez@storybridge.org>2011-04-10 18:46:58 +1000
commit7688cb7c47e9f2122e545243a3ce4c96dc381ee6 (patch)
treeeec69bdaa0c22bf7c9716c41eb3e1865731f5d04 /src
parentf51959b71f65fca1d7f1f875796492f445eb511c (diff)
Fix functionality that fails in release build.
Shown up by unit test which fails in release mode. Casting to/from enums... no good will ever come of it.
Diffstat (limited to 'src')
-rw-r--r--src/threed/arrays/qglattributeset.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/threed/arrays/qglattributeset.h b/src/threed/arrays/qglattributeset.h
index 39aed5bae..652ff57f0 100644
--- a/src/threed/arrays/qglattributeset.h
+++ b/src/threed/arrays/qglattributeset.h
@@ -75,26 +75,34 @@ public:
bool operator!=(const QGLAttributeSet &other) const;
private:
+ bool isValidAttr(QGL::VertexAttribute attr) const;
+
quint32 m_attrs;
};
+inline bool QGLAttributeSet::isValidAttr(QGL::VertexAttribute attr) const
+{
+ int a = int(attr);
+ return (a > -1 && a < 32);
+}
+
inline bool QGLAttributeSet::contains(QGL::VertexAttribute attr) const
{
quint32 flag = quint32(attr);
- return flag < 32 ? ((m_attrs & (((quint32)1) << flag)) != 0) : false;
+ return isValidAttr(attr) ? ((m_attrs & (((quint32)1) << flag)) != 0) : false;
}
inline void QGLAttributeSet::insert(QGL::VertexAttribute attr)
{
quint32 flag = quint32(attr);
- if (flag < 32)
+ if (isValidAttr(attr))
m_attrs |= (((quint32)1) << flag);
}
inline void QGLAttributeSet::remove(QGL::VertexAttribute attr)
{
quint32 flag = quint32(attr);
- if (flag < 32)
+ if (isValidAttr(attr))
m_attrs &= ~(((quint32)1) << flag);
}