summaryrefslogtreecommitdiffstats
path: root/examples/opengl/hellowindow/hellowindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/opengl/hellowindow/hellowindow.cpp')
-rw-r--r--examples/opengl/hellowindow/hellowindow.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/examples/opengl/hellowindow/hellowindow.cpp b/examples/opengl/hellowindow/hellowindow.cpp
index 3c314d9bc2..7770949d45 100644
--- a/examples/opengl/hellowindow/hellowindow.cpp
+++ b/examples/opengl/hellowindow/hellowindow.cpp
@@ -60,8 +60,7 @@ Renderer::Renderer(const QSurfaceFormat &format, Renderer *share, QScreen *scree
}
HelloWindow::HelloWindow(const QSharedPointer<Renderer> &renderer)
- : m_colorIndex(0)
- , m_renderer(renderer)
+ : m_colorIndex(0), m_renderer(renderer), m_timer(0)
{
setSurfaceType(QWindow::OpenGLSurface);
setWindowFlags(Qt::Window | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
@@ -84,9 +83,11 @@ void HelloWindow::exposeEvent(QExposeEvent *event)
render();
- QTimer *timer = new QTimer(this);
- connect(timer, SIGNAL(timeout()), this, SLOT(render()));
- timer->start(10);
+ if (!m_timer) {
+ m_timer = new QTimer(this);
+ connect(m_timer, SIGNAL(timeout()), this, SLOT(render()));
+ m_timer->start(10);
+ }
}
void HelloWindow::mousePressEvent(QMouseEvent *)