@@ -72,6 +72,13 @@ OcctQQuickFramebufferViewer::OcctQQuickFramebufferViewer(QQuickItem* theParent)
7272 // setAcceptTouchEvents(true); // necessary to recieve QTouchEvent events
7373 setAcceptHoverEvents (true );
7474 setMirrorVertically (true );
75+
76+ // GUI elements cannot be created from GL rendering thread - make queued connection
77+ connect (this , &OcctQQuickFramebufferViewer::glCriticalError, this , [this ](QString theMsg)
78+ {
79+ QMessageBox::critical (0 , " Critical error" , theMsg);
80+ QApplication::exit (1 );
81+ }, Qt::QueuedConnection);
7582}
7683
7784// ================================================================
@@ -437,8 +444,7 @@ void OcctQQuickFramebufferViewer::initializeGL(QOpenGLFramebufferObject* theFbo)
437444 const bool isFirstInit = myView->Window ().IsNull ();
438445 if (!OcctGlTools::InitializeGlWindow (myView, aNativeWin, aViewSize))
439446 {
440- QMessageBox::critical (0 , " Failure" , " OpenGl_Context is unable to wrap OpenGL context" );
441- QApplication::exit (1 );
447+ Q_EMIT glCriticalError (" OpenGl_Context is unable to wrap OpenGL context" );
442448 return ;
443449 }
444450
@@ -483,8 +489,7 @@ void OcctQQuickFramebufferViewer::render(QOpenGLFramebufferObject* theFbo)
483489 // wrap FBO created by QOpenGLFramebufferObject
484490 if (!OcctGlTools::InitializeGlFbo (myView))
485491 {
486- QMessageBox::critical (0 , " Failure" , " Default FBO wrapper creation failed" );
487- QApplication::exit (1 );
492+ Q_EMIT glCriticalError (" Default FBO wrapper creation failed" );
488493 return ;
489494 }
490495
0 commit comments