Merge pull request #6485 from deathbeam/gpu-null-check

Null-check GL and window on plugin shutdown
This commit is contained in:
Tomas Slusny
2018-11-20 10:36:43 +01:00
committed by GitHub

View File

@@ -320,45 +320,52 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
{
clientThread.invoke(() ->
{
if (textureArrayId != -1)
{
textureManager.freeTextureArray(gl, textureArrayId);
textureArrayId = -1;
}
client.setGpu(false);
client.setDrawCallbacks(null);
if (bufferId != -1)
if (gl != null)
{
GLUtil.glDeleteBuffer(gl, bufferId);
bufferId = -1;
if (textureArrayId != -1)
{
textureManager.freeTextureArray(gl, textureArrayId);
textureArrayId = -1;
}
if (bufferId != -1)
{
GLUtil.glDeleteBuffer(gl, bufferId);
bufferId = -1;
}
if (uvBufferId != -1)
{
GLUtil.glDeleteBuffer(gl, uvBufferId);
uvBufferId = -1;
}
if (uniformBufferId != -1)
{
GLUtil.glDeleteBuffer(gl, uniformBufferId);
uniformBufferId = -1;
}
shutdownInterfaceTexture();
shutdownProgram();
shutdownVao();
if (!jawtWindow.getLock().isLocked())
{
jawtWindow.lockSurface();
}
glContext.destroy();
}
if (uvBufferId != -1)
if (jawtWindow != null)
{
GLUtil.glDeleteBuffer(gl, uvBufferId);
uvBufferId = -1;
NewtFactoryAWT.destroyNativeWindow(jawtWindow);
}
if (uniformBufferId != -1)
{
GLUtil.glDeleteBuffer(gl, uniformBufferId);
uniformBufferId = -1;
}
shutdownInterfaceTexture();
shutdownProgram();
shutdownVao();
if (!jawtWindow.getLock().isLocked())
{
jawtWindow.lockSurface();
}
glContext.destroy();
NewtFactoryAWT.destroyNativeWindow(jawtWindow);
jawtWindow = null;
gl = null;
glDrawable = null;