File tree Expand file tree Collapse file tree 1 file changed +17
-8
lines changed Expand file tree Collapse file tree 1 file changed +17
-8
lines changed Original file line number Diff line number Diff line change 3434
3535#include " libvis/glew.h"
3636#include " libvis/logging.h"
37+ #include " libvis/qt_thread.h"
3738
3839namespace vis {
3940
4041OpenGLContextQt::~OpenGLContextQt () {
4142 // Delete the surface (since we always own it), but not the context (we might
4243 // own it, but then it should be deleted by Deinitialize()).
43- delete surface;
44+ if (surface) {
45+ RunInQtThreadBlocking ([&](){
46+ delete surface;
47+ });
48+ }
4449}
4550
4651bool OpenGLContextQt::InitializeWindowless (OpenGLContextImpl* sharing_context) {
@@ -71,17 +76,21 @@ bool OpenGLContextQt::InitializeWindowless(OpenGLContextImpl* sharing_context) {
7176
7277 surface = new QOffscreenSurface ();
7378 surface->setFormat (context->format ());
74- // NOTE: On some platforms, create() must be called on the main (GUI) thread.
75- // This is not enforced here at all.
76- surface-> create ( );
79+ RunInQtThreadBlocking ([&](){
80+ surface-> create ();
81+ } );
7782
7883 return true ;
7984}
8085
8186void OpenGLContextQt::Deinitialize () {
8287 delete context;
8388 context = nullptr ;
84- delete surface;
89+ if (surface) {
90+ RunInQtThreadBlocking ([&](){
91+ delete surface;
92+ });
93+ }
8594 surface = nullptr ;
8695}
8796
@@ -94,9 +103,9 @@ void OpenGLContextQt::AttachToCurrent() {
94103
95104 surface = new QOffscreenSurface ();
96105 surface->setFormat (context->format ());
97- // NOTE: On some platforms, create() must be called on the main (GUI) thread.
98- // This is not enforced here at all.
99- surface-> create ( );
106+ RunInQtThreadBlocking ([&](){
107+ surface-> create ();
108+ } );
100109 }
101110}
102111
You can’t perform that action at this time.
0 commit comments