diff --git a/src/Viewer/GraphicsWindowQt5.cpp b/src/Viewer/GraphicsWindowQt5.cpp index ae4928d53..9182d526e 100644 --- a/src/Viewer/GraphicsWindowQt5.cpp +++ b/src/Viewer/GraphicsWindowQt5.cpp @@ -174,23 +174,6 @@ GLWindow::~GLWindow() } } -void GLWindow::processDeferredEvents() -{ - QQueue deferredEventQueueCopy; - { - QMutexLocker lock(&_deferredEventQueueMutex); - deferredEventQueueCopy = _deferredEventQueue; - _eventCompressor.clear(); - _deferredEventQueue.clear(); - } - - while (!deferredEventQueueCopy.isEmpty()) - { - QEvent event(deferredEventQueueCopy.dequeue()); - QWindow::event(&event); - } -} - bool GLWindow::event( QEvent* event ) { if (event->type() == QEvent::WindowStateChange) { @@ -201,37 +184,9 @@ bool GLWindow::event( QEvent* event ) fgSetBool("/sim/startup/fullscreen", isFullscreen); } } - - // Reparenting GLWidget may create a new underlying window and a new GL context. - // Qt will then call doneCurrent on the GL context about to be deleted. The thread - // where old GL context was current has no longer current context to render to and - // we cannot make new GL context current in this thread. - - // We workaround above problems by deferring execution of problematic event requests. - // These events has to be enqueue and executed later in a main GUI thread (GUI operations - // outside the main thread are not allowed) just before makeCurrent is called from the - // right thread. The good place for doing that is right after swap in a swapBuffersImplementation. - - if (event->type() == QEvent::Hide) - { - // enqueue only the last of QEvent::Hide and QEvent::Show - enqueueDeferredEvent(QEvent::Hide, QEvent::Show); - return true; - } - else if (event->type() == QEvent::Show) - { - // enqueue only the last of QEvent::Show or QEvent::Hide - enqueueDeferredEvent(QEvent::Show, QEvent::Hide); - return true; - } - else if (event->type() == QEvent::ParentChange) - { - // enqueue only the last QEvent::ParentChange - enqueueDeferredEvent(QEvent::ParentChange); - return true; - } else if (event->type() == QEvent::UpdateRequest) { + qWarning() << "Got update request"; osg::ref_ptr v; if (_gw->_viewer.lock(v)) { v->frame(); @@ -729,18 +684,12 @@ void GraphicsWindowQt5::requestWarpPointer( float x, float y ) bool GraphicsWindowQt5::checkEvents() { - // this gets run on the main thread - if (_window->getNumDeferredEvents() > 0) - _window->processDeferredEvents(); - if (_sendResizeOnEventCheck) { _sendResizeOnEventCheck = false; _window->syncGeometryWithOSG(); - } // todo - only if not running inside QApplication::exec; can we check this? - QCoreApplication::processEvents(QEventLoop::AllEvents); return true; diff --git a/src/Viewer/GraphicsWindowQt5.hxx b/src/Viewer/GraphicsWindowQt5.hxx index 2c5769669..6fde22248 100644 --- a/src/Viewer/GraphicsWindowQt5.hxx +++ b/src/Viewer/GraphicsWindowQt5.hxx @@ -81,36 +81,10 @@ private slots: protected: void syncGeometryWithOSG(); - int getNumDeferredEvents() - { - QMutexLocker lock(&_deferredEventQueueMutex); - return _deferredEventQueue.count(); - } - void enqueueDeferredEvent(QEvent::Type eventType, QEvent::Type removeEventType = QEvent::None) - { - QMutexLocker lock(&_deferredEventQueueMutex); - - if (removeEventType != QEvent::None) - { - if (_deferredEventQueue.removeOne(removeEventType)) - _eventCompressor.remove(eventType); - } - - if (_eventCompressor.find(eventType) == _eventCompressor.end()) - { - _deferredEventQueue.enqueue(eventType); - _eventCompressor.insert(eventType); - } - } - void processDeferredEvents(); - + friend class GraphicsWindowQt5; GraphicsWindowQt5* _gw = nullptr; // back-pointer - QMutex _deferredEventQueueMutex; - QQueue _deferredEventQueue; - QSet _eventCompressor; - bool _forwardKeyEvents = false; qreal _devicePixelRatio = 1.0;