From 1b7256d344df2a3278a0ff5e3e3fdc33e3a56adf Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Mon, 11 Apr 2016 12:43:49 -0700 Subject: [PATCH] Clean shutdown for Texture Transfer thread --- libraries/gpu/src/gpu/GLBackendTextureTransfer.cpp | 11 +++++++++++ libraries/gpu/src/gpu/GLBackendTextureTransfer.h | 1 + 2 files changed, 12 insertions(+) diff --git a/libraries/gpu/src/gpu/GLBackendTextureTransfer.cpp b/libraries/gpu/src/gpu/GLBackendTextureTransfer.cpp index 907bc6a538..257ce85c02 100644 --- a/libraries/gpu/src/gpu/GLBackendTextureTransfer.cpp +++ b/libraries/gpu/src/gpu/GLBackendTextureTransfer.cpp @@ -44,6 +44,17 @@ GLTextureTransferHelper::GLTextureTransferHelper() { _canvas->doneCurrent(); initialize(true, QThread::LowPriority); _canvas->moveToThreadWithContext(_thread); + + // Clean shutdown on UNIX, otherwise _canvas is freed early + connect(qApp, &QCoreApplication::aboutToQuit, [&] { terminate(); }); +#endif +} + +GLTextureTransferHelper::~GLTextureTransferHelper() { +#ifdef THREADED_TEXTURE_TRANSFER + if (isStillRunning()) { + terminate(); + } #endif } diff --git a/libraries/gpu/src/gpu/GLBackendTextureTransfer.h b/libraries/gpu/src/gpu/GLBackendTextureTransfer.h index 1e850586d4..a3fae74213 100644 --- a/libraries/gpu/src/gpu/GLBackendTextureTransfer.h +++ b/libraries/gpu/src/gpu/GLBackendTextureTransfer.h @@ -23,6 +23,7 @@ struct TextureTransferPackage { class GLTextureTransferHelper : public GenericQueueThread { public: GLTextureTransferHelper(); + ~GLTextureTransferHelper(); void transferTexture(const gpu::TexturePointer& texturePointer); void postTransfer(const gpu::TexturePointer& texturePointer);