diff --git a/src/slic3r/GUI/GLTexture.cpp b/src/slic3r/GUI/GLTexture.cpp index f3421f150..516f8b934 100644 --- a/src/slic3r/GUI/GLTexture.cpp +++ b/src/slic3r/GUI/GLTexture.cpp @@ -27,10 +27,13 @@ namespace GUI { void GLTexture::Compressor::reset() { - // force compression completion, if any - m_abort_compressing = true; - // wait for compression completion, if any - while (m_is_compressing) {} + if (m_is_compressing) + { + // force compression completion, if any + m_abort_compressing = true; + // wait for compression completion, if any + while (m_is_compressing) {} + } m_levels.clear(); } @@ -42,8 +45,6 @@ void GLTexture::Compressor::add_level(unsigned int w, unsigned int h, const std: void GLTexture::Compressor::start_compressing() { - m_is_compressing = true; - m_abort_compressing = false; std::thread t(&GLTexture::Compressor::compress, this); t.detach(); } @@ -97,6 +98,9 @@ void GLTexture::Compressor::compress() { // reference: https://github.com/Cyan4973/RygsDXTc + m_is_compressing = true; + m_abort_compressing = false; + for (Level& level : m_levels) { if (m_abort_compressing) diff --git a/src/slic3r/GUI/GLTexture.hpp b/src/slic3r/GUI/GLTexture.hpp index 7fc5b8fcf..ec362944d 100644 --- a/src/slic3r/GUI/GLTexture.hpp +++ b/src/slic3r/GUI/GLTexture.hpp @@ -32,6 +32,7 @@ namespace GUI { public: explicit Compressor(GLTexture& texture) : m_texture(texture), m_is_compressing(false), m_abort_compressing(false) {} + ~Compressor() { reset(); } void reset();