diff options
author | Samuel Rødal <sroedal@trolltech.com> | 2008-06-24 16:02:39 +0200 |
---|---|---|
committer | Samuel Rødal <sroedal@trolltech.com> | 2008-06-24 16:02:39 +0200 |
commit | f308c15062e034faaeb6544ebad62797d71c8743 (patch) | |
tree | f828ea5f4ef550243736cd1b336b05ebd309d94e | |
parent | 1f90aed820a4e47730b44aa954057256c3fa838c (diff) |
Make sure m_model is always non-null.
-rw-r--r-- | model.cpp | 4 | ||||
-rw-r--r-- | model.h | 1 | ||||
-rw-r--r-- | openglscene.cpp | 5 |
3 files changed, 7 insertions, 3 deletions
@@ -27,6 +27,10 @@ bool operator==(const Edge &a, const Edge &b) || (a.pointA == b.pointB && a.pointB == b.pointA); } +Model::Model() +{ +} + Model::Model(const QString &filename) { QFile file(filename); @@ -10,6 +10,7 @@ class Model { public: + Model(); Model(const QString &filename); void render(bool wireframe = false, bool normals = false) const; diff --git a/openglscene.cpp b/openglscene.cpp index 6a7e096..40f16ca 100644 --- a/openglscene.cpp +++ b/openglscene.cpp @@ -136,7 +136,7 @@ OpenGLScene::OpenGLScene() , m_normalsEnabled(false) , m_rotating(false) , m_distance(1.4f) - , m_model(0) + , m_model(new Model) , m_lastTime(0) , m_angularMomentum(0, 40, 0) { @@ -186,8 +186,7 @@ void OpenGLScene::drawBackground(QPainter *painter, const QRectF &) glRotatef(m_rotation.z, 0, 0, 1); glEnable(GL_MULTISAMPLE); - if (m_model) - m_model->render(m_wireframeEnabled, m_normalsEnabled); + m_model->render(m_wireframeEnabled, m_normalsEnabled); glDisable(GL_MULTISAMPLE); glPopMatrix(); |