From 14b58a3a493db00aeb37f16118e774100a851017 Mon Sep 17 00:00:00 2001
From: Martin Schultz <Martin.Schultz@rwth-aachen.de>
Date: Tue, 8 Aug 2017 15:41:52 +0200
Subject: [PATCH] fixed #3 by moving the call to make curront to the top of
 snapshot function to prevent the push calls being made without a valid
 context or a different context than the pop calls.

---
 widgets/glWidget/QtBaseViewer.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/widgets/glWidget/QtBaseViewer.cc b/widgets/glWidget/QtBaseViewer.cc
index f109b835..4256dc9b 100644
--- a/widgets/glWidget/QtBaseViewer.cc
+++ b/widgets/glWidget/QtBaseViewer.cc
@@ -2200,7 +2200,8 @@ void glViewer::slotPropertiesUpdated() {
 }
 
 void glViewer::snapshot(QImage& _image, int _width, int _height, bool _alpha, bool _hideCoordsys, int samples) {
-    
+    makeCurrent();
+
     int w = 0, h = 0, bak_w = 0, bak_h = 0, left = 0, bottom = 0;
     
     glstate_->push_modelview_matrix();
@@ -2240,7 +2241,6 @@ void glViewer::snapshot(QImage& _image, int _width, int _height, bool _alpha, bo
     // it will fall back to the maximal supported number of samples
     format.setSamples(samples);
 
-    makeCurrent();
     QFramebufferObject fb(w,h,format);
 
     if ( fb.isValid() ){
-- 
GitLab