Counting the amount of surface objects, so we can see if there are multiple in memory when we have bugs.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2365 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-12-07 15:12:04 +00:00
parent 1a471ec77f
commit 83d244c3bf
5 changed files with 116 additions and 140 deletions

View file

@ -45,6 +45,7 @@ namespace Greenshot.Drawing {
/// </summary>
public class Surface : Control, ISurface {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(Surface));
public static int Count = 0;
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
/// <summary>
@ -360,7 +361,8 @@ namespace Greenshot.Drawing {
/// Base Surface constructor
/// </summary>
public Surface() : base(){
LOG.Debug("Creating a surface!");
Count++;
LOG.Debug("Creating surface!");
this.MouseDown += new MouseEventHandler(SurfaceMouseDown);
this.MouseUp += new MouseEventHandler(SurfaceMouseUp);
this.MouseMove += new MouseEventHandler(SurfaceMouseMove);
@ -427,7 +429,8 @@ namespace Greenshot.Drawing {
/// Will call the GarbageCollector to SuppressFinalize, preventing being cleaned twice
/// </summary>
public new void Dispose() {
LOG.Debug("Disposing a surface!");
Count--;
LOG.Debug("Disposing surface!");
if (buffer != null) {
buffer.Dispose();
buffer = null;
@ -438,10 +441,10 @@ namespace Greenshot.Drawing {
}
// Cleanup undo/redo stacks
while(undoStack != null && undoStack.Count > 0) {
while (undoStack != null && undoStack.Count > 0) {
undoStack.Pop().Dispose();
}
while(redoStack != null && redoStack.Count > 0) {
while (redoStack != null && redoStack.Count > 0) {
redoStack.Pop().Dispose();
}
base.Dispose();