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);