Two small fixes (#904)

* Fix index check in CSelectSlide.RenameValue

The check used && instead of ||. An index cannot be negative and out
of range at the same time, so the check never returned early and an
invalid index caused an ArgumentOutOfRangeException.

* Allow textures to be disposed more than once

CTextureBase.Dispose threw ObjectDisposedException on a second call.
Dispose must be safe to call multiple times, otherwise freeing a
texture twice crashes the game.

Return early instead. CD3DTexture and COGLTexture also check
IsDisposed first, so a second call does not free the GPU texture
again. This matters for OpenGL, where the texture name may already
belong to another texture.

---------

Co-authored-by: Florian Ostertag <flokuep@users.noreply.github.com>
This commit is contained in:
McSchneidarandFlorian Ostertag authored and GitHub committed 2026-10-16 05:53:10 +02:00
1 parent 2a6be1b3fe
commit df412b6d33
4 files changed
+15 -5

No files matched your search

+5
View File
@@ -65,6 +65,11 @@ namespace Vocaluxe.Lib.Draw
public override void Dispose()
{
if (IsDisposed)
{
return;
}
base.Dispose();
if (D3DTexture != null)
{
+5
View File
@@ -91,6 +91,11 @@ namespace Vocaluxe.Lib.Draw
public override void Dispose()
{
if (IsDisposed)
{
return;
}
base.Dispose();
if (Name != 0)
{
+4 -4
View File
@@ -92,17 +92,17 @@ namespace Vocaluxe.Lib.Draw
}
}
private bool _IsDisposed;
protected bool IsDisposed { get; private set; }
public virtual void Dispose()
{
if (_IsDisposed)
if (IsDisposed)
{
throw new ObjectDisposedException(GetType().Name);
return;
}
RefCount = 0;
_IsDisposed = true;
IsDisposed = true;
}
}
}
+1 -1
View File
@@ -389,7 +389,7 @@ namespace VocaluxeLib.Menu
public void RenameValue(int index, string newName, CTextureRef newTexture = null)
{
if (index < 0 && index >= _Values.Count)
if (index < 0 || index >= _Values.Count)
{
return;
}