From 217a00a53737bf1068d0bd15556af8aabe0776d9 Mon Sep 17 00:00:00 2001
From: Gabriel Studer <gabriel.studer@unibas.ch>
Date: Wed, 6 Feb 2019 19:29:21 +0100
Subject: [PATCH] nicely unregister GLCanvas from scene when destructor is
 called

---
 modules/gui/src/gl_canvas.cc | 4 ++++
 modules/gui/src/gl_canvas.hh | 1 +
 2 files changed, 5 insertions(+)

diff --git a/modules/gui/src/gl_canvas.cc b/modules/gui/src/gl_canvas.cc
index c6f28c8a5..449f7bb3b 100644
--- a/modules/gui/src/gl_canvas.cc
+++ b/modules/gui/src/gl_canvas.cc
@@ -41,6 +41,10 @@ ost::gui::GLCanvas::GLCanvas(): QOpenGLWindow(),
   gfx::Scene::Instance().Register(this);  
 }
 
+ost::gui::GLCanvas::~GLCanvas() {
+  gfx::Scene::Instance().Unregister(this);
+}
+
 void GLCanvas::StatusMessage(const String& m) {
   // This Window can also be displayed without a full blown GostyApp.
   // We therefore only feed the message into Gosty if there's already
diff --git a/modules/gui/src/gl_canvas.hh b/modules/gui/src/gl_canvas.hh
index 4d87a259a..7f7c89e08 100644
--- a/modules/gui/src/gl_canvas.hh
+++ b/modules/gui/src/gl_canvas.hh
@@ -37,6 +37,7 @@ class GLCanvas : public QOpenGLWindow, public gfx::GLWinBase {
 
 public:
   GLCanvas();
+  virtual ~GLCanvas();
 
   // gfx::GLWinBase interface
   virtual void MakeActive() { this->makeCurrent(); }
-- 
GitLab