diff --git a/extern/osgQt/GraphicsWindowQt b/extern/osgQt/GraphicsWindowQt index 1e34fc9db6..274f0a149f 100644 --- a/extern/osgQt/GraphicsWindowQt +++ b/extern/osgQt/GraphicsWindowQt @@ -14,8 +14,6 @@ #ifndef OSGVIEWER_GRAPHICSWINDOWQT #define OSGVIEWER_GRAPHICSWINDOWQT -#include - #include #include diff --git a/extern/osgQt/GraphicsWindowQt.cpp b/extern/osgQt/GraphicsWindowQt.cpp index 0135a1784b..af963c04b5 100644 --- a/extern/osgQt/GraphicsWindowQt.cpp +++ b/extern/osgQt/GraphicsWindowQt.cpp @@ -22,12 +22,6 @@ #include #endif -#if (QT_VERSION>=QT_VERSION_CHECK(4, 6, 0)) -# define USE_GESTURES -# include -# include -#endif - using namespace osgQt; #if (QT_VERSION < QT_VERSION_CHECK(5, 2, 0)) @@ -132,6 +126,8 @@ bool GLWidget::event( QEvent* event ) void GLWidget::resizeEvent( QResizeEvent* event ) { + if (_gw == nullptr || !_gw->valid()) + return; const QSize& size = event->size(); int scaled_width = static_cast(size.width()*_devicePixelRatio); @@ -143,6 +139,8 @@ void GLWidget::resizeEvent( QResizeEvent* event ) void GLWidget::moveEvent( QMoveEvent* event ) { + if (_gw == nullptr || !_gw->valid()) + return; const QPoint& pos = event->pos(); int scaled_width = static_cast(width()*_devicePixelRatio); int scaled_height = static_cast(height()*_devicePixelRatio); @@ -527,9 +525,6 @@ void GraphicsWindowQt::swapBuffersImplementation() if (!_widget || !_widget->windowHandle()->isExposed()) return; #endif - - _widget->swapBuffers(); - // FIXME: the processDeferredEvents should really be executed in a GUI (main) thread context but // I couln't find any reliable way to do this. For now, lets hope non of *GUI thread only operations* will // be executed in a QGLWidget::event handler. On the other hand, calling GUI only operations in the @@ -539,8 +534,8 @@ void GraphicsWindowQt::swapBuffersImplementation() // We need to call makeCurrent here to restore our previously current context // which may be changed by the processDeferredEvents function. - if (QGLContext::currentContext() != _widget->context()) - _widget->makeCurrent(); + _widget->makeCurrent(); + _widget->swapBuffers(); } void GraphicsWindowQt::requestWarpPointer( float x, float y )