From 98e836169005e7f143092c171c59bf3ecc044d39 Mon Sep 17 00:00:00 2001 From: luiscuenca Date: Thu, 30 Nov 2017 16:07:43 -0700 Subject: [PATCH] Fix and rebuild --- libraries/ui/src/ui/OffscreenQmlSurface.cpp | 10 +++------- libraries/ui/src/ui/OffscreenQmlSurface.h | 2 ++ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/libraries/ui/src/ui/OffscreenQmlSurface.cpp b/libraries/ui/src/ui/OffscreenQmlSurface.cpp index 019897e5c3..c9fe738940 100644 --- a/libraries/ui/src/ui/OffscreenQmlSurface.cpp +++ b/libraries/ui/src/ui/OffscreenQmlSurface.cpp @@ -139,7 +139,7 @@ public: QThread::msleep(_runDelayMs); } auto rootItem = _surface->getRootItem(); - if (rootItem) { + if (rootItem && !_surface->getCleaned()) { for (auto player : rootItem->findChildren()) { auto mediaState = player->state(); QMediaService *svc = player->service(); @@ -165,12 +165,7 @@ public: svc->releaseControl(out); // if multimedia was paused, it will start playing automatically after changing audio device // this will reset it back to a paused state - if (mediaState == QMediaPlayer::State::PausedState) { - player->pause(); - } - else if (mediaState == QMediaPlayer::State::StoppedState) { - player->stop(); - } + } } qDebug() << "QML Audio changed to " << _newTargetDevice; @@ -504,6 +499,7 @@ QOpenGLContext* OffscreenQmlSurface::getSharedContext() { } void OffscreenQmlSurface::cleanup() { + _isCleaned = true; _canvas->makeCurrent(); _renderControl->invalidate(); diff --git a/libraries/ui/src/ui/OffscreenQmlSurface.h b/libraries/ui/src/ui/OffscreenQmlSurface.h index 44c6c3c77b..371b110aa9 100644 --- a/libraries/ui/src/ui/OffscreenQmlSurface.h +++ b/libraries/ui/src/ui/OffscreenQmlSurface.h @@ -75,6 +75,7 @@ public: void pause(); void resume(); bool isPaused() const; + bool getCleaned() { return _isCleaned; } void setBaseUrl(const QUrl& baseUrl); QQuickItem* getRootItem(); @@ -177,6 +178,7 @@ private: bool _polish { true }; bool _paused { true }; bool _focusText { false }; + bool _isCleaned{ false }; uint8_t _maxFps { 60 }; MouseTranslator _mouseTranslator { [](const QPointF& p) { return p.toPoint(); } }; QWindow* _proxyWindow { nullptr };