cairo: Make debug more robust

This commit is contained in:
Michael Hutchinson 2013-03-06 00:09:01 -05:00 committed by Bertrand Lorentz
parent 6e7527cb92
commit 50ee23f0f2

View File

@ -50,7 +50,7 @@ namespace Cairo {
if (!Enabled) if (!Enabled)
throw new InvalidOperationException (); throw new InvalidOperationException ();
traces.Add (obj, Environment.StackTrace); traces[obj] = Environment.StackTrace;
} }
public static void OnDisposed<T> (IntPtr obj, bool disposing) public static void OnDisposed<T> (IntPtr obj, bool disposing)
@ -61,8 +61,11 @@ namespace Cairo {
if (!disposing) { if (!disposing) {
Console.Error.WriteLine ("{0} is leaking, programmer is missing a call to Dispose", typeof(T).FullName); Console.Error.WriteLine ("{0} is leaking, programmer is missing a call to Dispose", typeof(T).FullName);
if (Enabled) { if (Enabled) {
Console.Error.WriteLine ("Allocated from:"); string val;
Console.Error.WriteLine (traces[obj]); if (traces.TryGetValue (obj, out val)) {
Console.Error.WriteLine ("Allocated from:");
Console.Error.WriteLine (val);
}
} else { } else {
Console.Error.WriteLine ("Set MONO_CAIRO_DEBUG_DISPOSE to track allocation traces"); Console.Error.WriteLine ("Set MONO_CAIRO_DEBUG_DISPOSE to track allocation traces");
} }