From b21d16a15f9147917e4deea1ce9ad4995785f931 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Mon, 6 Aug 2018 13:26:26 +0200 Subject: [PATCH] fix(Camera): share opengl context, avoid reset of window id --- src/app/AppController.cpp | 3 +++ src/components/camera/Camera.cpp | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/app/AppController.cpp b/src/app/AppController.cpp index bb9314765..653407fd0 100644 --- a/src/app/AppController.cpp +++ b/src/app/AppController.cpp @@ -50,6 +50,9 @@ AppController::AppController (int &argc, char *argv[]) { QGuiApplication::setAttribute(Qt::AA_DisableHighDpiScaling, true); + // Useful to share camera on Fullscreen (other context). + QApplication::setAttribute(Qt::AA_ShareOpenGLContexts); + // --------------------------------------------------------------------------- // App creation. // --------------------------------------------------------------------------- diff --git a/src/components/camera/Camera.cpp b/src/components/camera/Camera.cpp index be23f6613..df113935e 100644 --- a/src/components/camera/Camera.cpp +++ b/src/components/camera/Camera.cpp @@ -56,12 +56,13 @@ CameraRenderer::~CameraRenderer () { qInfo() << QStringLiteral("Delete context info:") << mContextInfo; CoreManager *coreManager = CoreManager::getInstance(); - coreManager->lockVideoRender(); - if (mIsPreview) - coreManager->getCore()->setNativePreviewWindowId(nullptr); - else if (mCall) + shared_ptr core = coreManager->getCore(); + if (mIsPreview) { + if (core->getNativePreviewWindowId() == mContextInfo) + core->setNativePreviewWindowId(nullptr); + } else if (mCall && mCall->getNativeVideoWindowId() == mContextInfo) mCall->setNativeVideoWindowId(nullptr); coreManager->unlockVideoRender();