From 8214683b39453622b5e9bc149e4214b85c0bcbce Mon Sep 17 00:00:00 2001 From: "Alexander V. Wolf" Date: Sat, 9 Dec 2023 23:06:05 +0700 Subject: [PATCH] Revert "Fix possible crashes" This reverts commit a2010eec897b3e01e76ed0ae33919006be2744e2. --- src/core/StelTexture.cpp | 51 ++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/src/core/StelTexture.cpp b/src/core/StelTexture.cpp index 0afe7fbcf5007..56dc2231c7072 100644 --- a/src/core/StelTexture.cpp +++ b/src/core/StelTexture.cpp @@ -46,36 +46,35 @@ StelTexture::StelTexture(StelTextureMgr *mgr) StelTexture::~StelTexture() { - if (id) + if (id != 0) { - if (id != 0) - { - /// FS: make sure the correct GL context is bound! - /// Causes #595 flicker in Night Mode with DSS/HiPS. Tentatively remove this. - //StelApp::getInstance().ensureGLContextCurrent(); + /// FS: make sure the correct GL context is bound! + /// Causes #595 flicker in Night Mode with DSS/HiPS. Tentatively remove this. + //StelApp::getInstance().ensureGLContextCurrent(); - if (gl->glIsTexture(id)==GL_FALSE) - { - GLenum err = gl->glGetError(); - qWarning() << "WARNING: in StelTexture::~StelTexture() tried to delete invalid texture with ID=" - << id << "Current GL ERROR status is" << err << "(" << StelOpenGL::getGLErrorText(err) << ")"; - } - else - { - gl->glDeleteTextures(1, &id); - textureMgr->glMemoryUsage -= glSize; - textureMgr->idMap.remove(id); - glSize = 0; - } - #ifndef NDEBUG - if (qApp->property("verbose") == true) - qDebug() << "Deleted StelTexture" << id << ", total memory usage " - << textureMgr->glMemoryUsage / (1024.0 * 1024.0)<<"MB"; - #endif - id = 0; + if (gl->glIsTexture(id)==GL_FALSE) + { + GLenum err = gl->glGetError(); + qWarning() << "WARNING: in StelTexture::~StelTexture() tried to delete invalid texture with ID=" + << id << "Current GL ERROR status is" << err << "(" << StelOpenGL::getGLErrorText(err) << ")"; } else - qWarning()<<"Cannot delete texture"<glDeleteTextures(1, &id); + textureMgr->glMemoryUsage -= glSize; + textureMgr->idMap.remove(id); + glSize = 0; + } +#ifndef NDEBUG + if (qApp->property("verbose") == true) + qDebug() << "Deleted StelTexture" << id << ", total memory usage " + << textureMgr->glMemoryUsage / (1024.0 * 1024.0)<<"MB"; +#endif + id = 0; + } + else if (id) + { + qWarning()<<"Cannot delete texture"<