Fixed possible memoryleak in loopmanager

This commit is contained in:
DarthAffe committed 2016-06-12 11:53:01 +02:00
1 parent eba34be67b
commit c61d0ddac3
1 file changed
+12 -9
+12 -9
View File
@@ -144,17 +144,20 @@ namespace Artemis.Managers
return;
// Fill the bitmap's background with black to avoid trailing colors on some keyboards
var fixedBmp = new Bitmap(bitmap.Width, bitmap.Height);
using (var g = Graphics.FromImage(fixedBmp))
// Bitmaps needs to be disposd!
using (var fixedBmp = new Bitmap(bitmap.Width, bitmap.Height))
{
g.Clear(Color.Black);
g.DrawImage(bitmap, 0, 0);
using (var g = Graphics.FromImage(fixedBmp))
{
g.Clear(Color.Black);
g.DrawImage(bitmap, 0, 0);
}
bitmap = fixedBmp;
// Update the keyboard
_deviceManager.ActiveKeyboard?.DrawBitmap(bitmap);
}
bitmap = fixedBmp;
// Update the keyboard
_deviceManager.ActiveKeyboard?.DrawBitmap(bitmap);
}
}
}