summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Rødal <sroedal@trolltech.com>2008-06-24 16:02:39 +0200
committerSamuel Rødal <sroedal@trolltech.com>2008-06-24 16:02:39 +0200
commitf308c15062e034faaeb6544ebad62797d71c8743 (patch)
treef828ea5f4ef550243736cd1b336b05ebd309d94e
parent1f90aed820a4e47730b44aa954057256c3fa838c (diff)
Make sure m_model is always non-null.
-rw-r--r--model.cpp4
-rw-r--r--model.h1
-rw-r--r--openglscene.cpp5
3 files changed, 7 insertions, 3 deletions
diff --git a/model.cpp b/model.cpp
index 09afbb5..f0c64c5 100644
--- a/model.cpp
+++ b/model.cpp
@@ -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);
diff --git a/model.h b/model.h
index b219f8f..bdd6cdf 100644
--- a/model.h
+++ b/model.h
@@ -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();