From 50ee23f0f22276fe1c48d92e5eab907919734425 Mon Sep 17 00:00:00 2001 From: Michael Hutchinson Date: Wed, 6 Mar 2013 00:09:01 -0500 Subject: [PATCH] cairo: Make debug more robust --- cairo/CairoDebug.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cairo/CairoDebug.cs b/cairo/CairoDebug.cs index ea1567931..43b370f8b 100644 --- a/cairo/CairoDebug.cs +++ b/cairo/CairoDebug.cs @@ -50,7 +50,7 @@ namespace Cairo { if (!Enabled) throw new InvalidOperationException (); - traces.Add (obj, Environment.StackTrace); + traces[obj] = Environment.StackTrace; } public static void OnDisposed (IntPtr obj, bool disposing) @@ -61,8 +61,11 @@ namespace Cairo { if (!disposing) { Console.Error.WriteLine ("{0} is leaking, programmer is missing a call to Dispose", typeof(T).FullName); if (Enabled) { - Console.Error.WriteLine ("Allocated from:"); - Console.Error.WriteLine (traces[obj]); + string val; + if (traces.TryGetValue (obj, out val)) { + Console.Error.WriteLine ("Allocated from:"); + Console.Error.WriteLine (val); + } } else { Console.Error.WriteLine ("Set MONO_CAIRO_DEBUG_DISPOSE to track allocation traces"); }