rollback fixes for bugz512

This commit is contained in:
Andrew Meadows 2019-06-13 13:57:18 -07:00
parent c347d46454
commit db3c7b9194
3 changed files with 17 additions and 34 deletions

View file

@ -256,28 +256,18 @@ void EntityTreeRenderer::clear() {
} }
// reset the engine // reset the engine
if (_wantScripts && !_shuttingDown) {
resetEntitiesScriptEngine();
}
// remove all entities from the scene
auto scene = _viewState->getMain3DScene(); auto scene = _viewState->getMain3DScene();
if (_shuttingDown) { if (scene) {
if (scene) { for (const auto& entry : _entitiesInScene) {
render::Transaction transaction; const auto& renderer = entry.second;
for (const auto& entry : _entitiesInScene) { fadeOutRenderable(renderer);
const auto& renderer = entry.second;
renderer->removeFromScene(scene, transaction);
}
scene->enqueueTransaction(transaction);
} }
} else { } else {
if (_wantScripts) { qCWarning(entitiesrenderer) << "EntitityTreeRenderer::clear(), Unexpected null scene, possibly during application shutdown";
resetEntitiesScriptEngine();
}
if (scene) {
for (const auto& entry : _entitiesInScene) {
const auto& renderer = entry.second;
fadeOutRenderable(renderer);
}
} else {
qCWarning(entitiesrenderer) << "EntitityTreeRenderer::clear(), Unexpected null scene";
}
} }
_entitiesInScene.clear(); _entitiesInScene.clear();
_renderablesToUpdate.clear(); _renderablesToUpdate.clear();

View file

@ -7,7 +7,6 @@
// //
#include "RenderableWebEntityItem.h" #include "RenderableWebEntityItem.h"
#include <atomic>
#include <QtCore/QTimer> #include <QtCore/QTimer>
#include <QtGui/QOpenGLContext> #include <QtGui/QOpenGLContext>
@ -47,7 +46,7 @@ static uint64_t MAX_NO_RENDER_INTERVAL = 30 * USECS_PER_SECOND;
static uint8_t YOUTUBE_MAX_FPS = 30; static uint8_t YOUTUBE_MAX_FPS = 30;
// Don't allow more than 20 concurrent web views // Don't allow more than 20 concurrent web views
static std::atomic<uint32_t> _currentWebCount(0); static uint32_t _currentWebCount { 0 };
static const uint32_t MAX_CONCURRENT_WEB_VIEWS = 20; static const uint32_t MAX_CONCURRENT_WEB_VIEWS = 20;
static QTouchDevice _touchDevice; static QTouchDevice _touchDevice;
@ -357,15 +356,16 @@ void WebEntityRenderer::buildWebSurface(const EntityItemPointer& entity, const Q
void WebEntityRenderer::destroyWebSurface() { void WebEntityRenderer::destroyWebSurface() {
QSharedPointer<OffscreenQmlSurface> webSurface; QSharedPointer<OffscreenQmlSurface> webSurface;
ContentType contentType = ContentType::NoContent;
withWriteLock([&] { withWriteLock([&] {
webSurface.swap(_webSurface); webSurface.swap(_webSurface);
_contentType = ContentType::NoContent; _contentType = contentType;
if (webSurface) {
--_currentWebCount;
WebEntityRenderer::releaseWebSurface(webSurface, _cachedWebSurface, _connections);
}
}); });
if (webSurface) {
--_currentWebCount;
WebEntityRenderer::releaseWebSurface(webSurface, _cachedWebSurface, _connections);
}
} }
glm::vec2 WebEntityRenderer::getWindowSize(const TypedEntityPointer& entity) const { glm::vec2 WebEntityRenderer::getWindowSize(const TypedEntityPointer& entity) const {
@ -469,12 +469,6 @@ void WebEntityRenderer::handlePointerEventAsMouse(const PointerEvent& event) {
QCoreApplication::sendEvent(_webSurface->getWindow(), &mouseEvent); QCoreApplication::sendEvent(_webSurface->getWindow(), &mouseEvent);
} }
void WebEntityRenderer::onRemoveFromSceneTyped(const TypedEntityPointer& entity) {
// HACK: destroyWebSurface() here to avoid a crash on shutdown.
// TODO: fix the real problem: EntityRenderer<>::dtor never called on shutdown for smart-pointer resource leak.
destroyWebSurface();
}
void WebEntityRenderer::setProxyWindow(QWindow* proxyWindow) { void WebEntityRenderer::setProxyWindow(QWindow* proxyWindow) {
withReadLock([&] { withReadLock([&] {
if (_webSurface) { if (_webSurface) {

View file

@ -64,7 +64,6 @@ protected:
void handlePointerEventAsTouch(const PointerEvent& event); void handlePointerEventAsTouch(const PointerEvent& event);
void handlePointerEventAsMouse(const PointerEvent& event); void handlePointerEventAsMouse(const PointerEvent& event);
void onRemoveFromSceneTyped(const TypedEntityPointer& entity) override;
private: private:
void onTimeout(); void onTimeout();
void buildWebSurface(const EntityItemPointer& entity, const QString& newSourceURL); void buildWebSurface(const EntityItemPointer& entity, const QString& newSourceURL);