1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-08-13 19:16:58 +02:00

Fix potential memory leaks with FlatProgressBar color brush

This commit is contained in:
2016-08-04 13:43:32 +02:00
parent ba6242e09d
commit 3775b5968d

@@ -3,9 +3,11 @@ using System.Windows.Forms;
namespace TweetDck.Core.Controls{
public partial class FlatProgressBar : ProgressBar{
private SolidBrush brush;
private readonly SolidBrush brush;
public FlatProgressBar(){
brush = new SolidBrush(Color.White);
SetStyle(ControlStyles.UserPaint,true);
SetStyle(ControlStyles.OptimizedDoubleBuffer,true);
}
@@ -15,8 +17,8 @@ namespace TweetDck.Core.Controls{
}
protected override void OnPaint(PaintEventArgs e){
if (brush == null || brush.Color != ForeColor){
brush = new SolidBrush(ForeColor);
if (brush.Color != ForeColor){
brush.Color = ForeColor;
}
Rectangle rect = e.ClipRectangle;
@@ -25,9 +27,11 @@ namespace TweetDck.Core.Controls{
}
protected override void Dispose(bool disposing){
if (brush != null)brush.Dispose();
base.Dispose(disposing);
if (disposing){
brush.Dispose();
}
}
}
}