Author: miguel
Date: 2007-12-10 17:46:05 -0500 (Mon, 10 Dec 2007)
New Revision: 91071

Modified:
   branches/mono-1-2-6/mcs/class/System/System.Diagnostics/ChangeLog
   
branches/mono-1-2-6/mcs/class/System/System.Diagnostics/DefaultTraceListener.cs
Log:
Backport



Modified: branches/mono-1-2-6/mcs/class/System/System.Diagnostics/ChangeLog
===================================================================
--- branches/mono-1-2-6/mcs/class/System/System.Diagnostics/ChangeLog   
2007-12-10 22:45:06 UTC (rev 91070)
+++ branches/mono-1-2-6/mcs/class/System/System.Diagnostics/ChangeLog   
2007-12-10 22:46:05 UTC (rev 91071)
@@ -1,3 +1,12 @@
+2007-12-10  Miguel de Icaza  <[EMAIL PROTECTED]>
+
+       * DefaultTraceListener.cs: By default set the AssertUiEnabled to
+       false, as this is what we had previously and some broken
+       applications (Tomboy) are too trigger happy with Debug.Assert. 
+
+       Also, we now load the Windows.Forms code on demand, instead of
+       preloading it on the static ctor to reduce memory usage.
+       
 2007-10-30  Robert Jordan  <[EMAIL PROTECTED]>
 
        * Process.cs: Wrap the redirected streams with a stream

Modified: 
branches/mono-1-2-6/mcs/class/System/System.Diagnostics/DefaultTraceListener.cs
===================================================================
--- 
branches/mono-1-2-6/mcs/class/System/System.Diagnostics/DefaultTraceListener.cs 
    2007-12-10 22:45:06 UTC (rev 91070)
+++ 
branches/mono-1-2-6/mcs/class/System/System.Diagnostics/DefaultTraceListener.cs 
    2007-12-10 22:46:05 UTC (rev 91071)
@@ -57,9 +57,6 @@
                private static readonly string MonoTracePrefix;
                private static readonly string MonoTraceFile;
 
-               private static readonly object 
messageBoxButtonsAbortRetryIgnore;
-               private static readonly MethodInfo msgboxShow;
-
                static DefaultTraceListener ()
                {
                        // Determine what platform we're on.  This impacts how 
where we send
@@ -110,19 +107,6 @@
                                        MonoTracePrefix = prefix;
                                }
                        }
-
-                       // AssertUiEnabled support
-                       try {
-                               Assembly wfAsm = Assembly.Load 
(Consts.AssemblySystem_Windows_Forms);
-                               if (wfAsm != null) {
-                                       Type buttons = wfAsm.GetType 
("System.Windows.Forms.MessageBoxButtons");
-                                       messageBoxButtonsAbortRetryIgnore = 
Enum.Parse (buttons, "AbortRetryIgnore");
-                                       msgboxShow = wfAsm.GetType 
("System.Windows.Forms.MessageBox").GetMethod ("Show", new Type [] {typeof 
(string), typeof (string), buttons});
-                               }
-                       } catch {
-                               // failed to load the assembly (likely when
-                               // MWF is not installed).
-                       }
                }
 
                /**
@@ -153,7 +137,7 @@
 
                private string logFileName = null;
 
-               private bool assertUiEnabled = true;
+               private bool assertUiEnabled = false;
 
                public DefaultTraceListener () : base ("Default")
                {
@@ -185,9 +169,30 @@
 
                DialogResult ProcessUI (string message, string detailMessage)
                {
-                       if (!AssertUiEnabled || msgboxShow == null || 
messageBoxButtonsAbortRetryIgnore == null)
+                       
+                       if (!AssertUiEnabled)
                                return DialogResult.None;
 
+                       object messageBoxButtonsAbortRetryIgnore;
+                       MethodInfo msgboxShow;
+                       
+                       try {
+                               Assembly wfAsm = Assembly.Load 
(Consts.AssemblySystem_Windows_Forms);
+                               if (wfAsm == null)
+                                   return DialogResult.None;
+                               
+                               Type buttons = wfAsm.GetType 
("System.Windows.Forms.MessageBoxButtons");
+                               messageBoxButtonsAbortRetryIgnore = Enum.Parse 
(buttons, "AbortRetryIgnore");
+                               msgboxShow = wfAsm.GetType 
("System.Windows.Forms.MessageBox").GetMethod (
+                                       "Show",
+                                       new Type [] {typeof (string), typeof 
(string), buttons});
+                       } catch {
+                               return DialogResult.None;
+                       }
+
+                       if (msgboxShow == null || 
messageBoxButtonsAbortRetryIgnore == null)
+                               return DialogResult.None;
+
                        string caption = String.Format ("Assertion Failed: {0} 
to quit, {1} to debug, {2} to continue", "Abort", "Retry", "Ignore");
                        string msg = String.Format ("{0}{1}{2}{1}{1}{3}", 
message, Environment.NewLine, detailMessage, new StackTrace ());
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to