Author: lluis
Date: 2007-08-14 10:20:21 -0400 (Tue, 14 Aug 2007)
New Revision: 84080

Modified:
   trunk/monodevelop/Core/src/MonoDevelop.Projects/ChangeLog
   
trunk/monodevelop/Core/src/MonoDevelop.Projects/MonoDevelop.Projects.Parser/ClassWrapper.cs
Log:
* MonoDevelop.Projects.Parser/ClassWrapper.cs: Added protection against
  exceptions thrown when reading class info from the database.

Modified: trunk/monodevelop/Core/src/MonoDevelop.Projects/ChangeLog
===================================================================
--- trunk/monodevelop/Core/src/MonoDevelop.Projects/ChangeLog   2007-08-14 
14:08:00 UTC (rev 84079)
+++ trunk/monodevelop/Core/src/MonoDevelop.Projects/ChangeLog   2007-08-14 
14:20:21 UTC (rev 84080)
@@ -1,5 +1,10 @@
 2007-08-14  Lluis Sanchez Gual <[EMAIL PROTECTED]> 
 
+       * MonoDevelop.Projects.Parser/ClassWrapper.cs: Added protection against
+         exceptions thrown when reading class info from the database.
+
+2007-08-14  Lluis Sanchez Gual <[EMAIL PROTECTED]> 
+
        * MonoDevelop.Projects.Parser/CompoundClass.cs: Don't add System.Object 
as
          base class if one of the parts has a different base class.
        * MonoDevelop.Projects.Parser/IReturnType.cs,

Modified: 
trunk/monodevelop/Core/src/MonoDevelop.Projects/MonoDevelop.Projects.Parser/ClassWrapper.cs
===================================================================
--- 
trunk/monodevelop/Core/src/MonoDevelop.Projects/MonoDevelop.Projects.Parser/ClassWrapper.cs
 2007-08-14 14:08:00 UTC (rev 84079)
+++ 
trunk/monodevelop/Core/src/MonoDevelop.Projects/MonoDevelop.Projects.Parser/ClassWrapper.cs
 2007-08-14 14:20:21 UTC (rev 84080)
@@ -1,5 +1,6 @@
 
 using System;
+using MonoDevelop.Core;
 
 namespace MonoDevelop.Projects.Parser
 {
@@ -21,6 +22,7 @@
                string ns;
                string name;
                IClass wrapped;
+               bool loaded;
                
                public ClassWrapper (CodeCompletionDatabase db, ClassEntry 
entry)
                {
@@ -35,9 +37,14 @@
                                // If the wrapper is required, it means that 
the user is trying to get some
                                // information not available in ClassEntry. In 
this case, read the full
                                // clas from the database.
-                               if (wrapped == null) {
-                                       wrapped = db.ReadClass (entry);
-                                       entry.AttachClass (wrapped);
+                               if (!loaded) {
+                                       loaded = true;
+                                       try {
+                                               wrapped = db.ReadClass (entry);
+                                               entry.AttachClass (wrapped);
+                                       } catch (Exception ex) {
+                                               Runtime.LoggingService.Error 
(ex);
+                                       }
                                }
                                return wrapped;
                        }
@@ -66,7 +73,7 @@
                
                public ICompilationUnit CompilationUnit {
                        get {
-                               if ((entry.ContentFlags & 
ContentFlags.HasCompilationUnit) != 0)
+                               if (Wrapped != null && (entry.ContentFlags & 
ContentFlags.HasCompilationUnit) != 0)
                                        return Wrapped.CompilationUnit;
                                else
                                        return null;
@@ -84,7 +91,7 @@
                
                public IRegion Region {
                        get {
-                               if ((entry.ContentFlags & 
ContentFlags.HasRegion) != 0)
+                               if (Wrapped != null && (entry.ContentFlags & 
ContentFlags.HasRegion) != 0)
                                        return Wrapped.Region;
                                else
                                        return null;
@@ -93,7 +100,7 @@
                
                public IRegion BodyRegion {
                        get {
-                               if ((entry.ContentFlags & 
ContentFlags.HasBodyRegion) != 0)
+                               if (Wrapped != null && (entry.ContentFlags & 
ContentFlags.HasBodyRegion) != 0)
                                        return Wrapped.BodyRegion;
                                else
                                        return null;
@@ -103,7 +110,7 @@
                // For classes composed by several files, returns all parts of 
the class
                public IClass[] Parts {
                        get {
-                               if ((entry.ContentFlags & 
ContentFlags.HasParts) != 0)
+                               if (Wrapped != null && (entry.ContentFlags & 
ContentFlags.HasParts) != 0)
                                        return Wrapped.Parts;
                                else
                                        return new IClass [0];
@@ -112,7 +119,7 @@
                
                public GenericParameterList GenericParameters {
                        get {
-                               if ((entry.ContentFlags & 
ContentFlags.HasGenericParams) != 0)
+                               if (Wrapped != null && (entry.ContentFlags & 
ContentFlags.HasGenericParams) != 0)
                                        return Wrapped.GenericParameters;
                                else
                                        return null;
@@ -121,7 +128,7 @@
                
                public ReturnTypeList BaseTypes {
                        get {
-                               if ((entry.ContentFlags & 
ContentFlags.HasBaseTypes) != 0)
+                               if (Wrapped != null && (entry.ContentFlags & 
ContentFlags.HasBaseTypes) != 0)
                                        return Wrapped.BaseTypes;
                                else
                                        return new ReturnTypeList ();
@@ -130,7 +137,7 @@
                
                public ClassCollection InnerClasses {
                        get {
-                               if ((entry.ContentFlags & 
ContentFlags.HasInnerClasses) != 0)
+                               if (Wrapped != null && (entry.ContentFlags & 
ContentFlags.HasInnerClasses) != 0)
                                        return Wrapped.InnerClasses;
                                else
                                        return new ClassCollection ();
@@ -139,7 +146,7 @@
 
                public FieldCollection Fields {
                        get {
-                               if ((entry.ContentFlags & 
ContentFlags.HasFields) != 0)
+                               if (Wrapped != null && (entry.ContentFlags & 
ContentFlags.HasFields) != 0)
                                        return Wrapped.Fields;
                                else
                                        return new FieldCollection (this);
@@ -148,7 +155,7 @@
 
                public PropertyCollection Properties {
                        get {
-                               if ((entry.ContentFlags & 
ContentFlags.HasProperties) != 0)
+                               if (Wrapped != null && (entry.ContentFlags & 
ContentFlags.HasProperties) != 0)
                                        return Wrapped.Properties;
                                else
                                        return new PropertyCollection (this);
@@ -157,7 +164,7 @@
 
                public IndexerCollection Indexer {
                        get {
-                               if ((entry.ContentFlags & 
ContentFlags.HasIndexers) != 0)
+                               if (Wrapped != null && (entry.ContentFlags & 
ContentFlags.HasIndexers) != 0)
                                        return Wrapped.Indexer;
                                else
                                        return new IndexerCollection (this);
@@ -166,7 +173,7 @@
 
                public MethodCollection Methods {
                        get {
-                               if ((entry.ContentFlags & 
ContentFlags.HasMethods) != 0)
+                               if (Wrapped != null && (entry.ContentFlags & 
ContentFlags.HasMethods) != 0)
                                        return Wrapped.Methods;
                                else
                                        return new MethodCollection (this);
@@ -175,7 +182,7 @@
 
                public EventCollection Events {
                        get {
-                               if ((entry.ContentFlags & 
ContentFlags.HasEvents) != 0)
+                               if (Wrapped != null && (entry.ContentFlags & 
ContentFlags.HasEvents) != 0)
                                        return Wrapped.Events;
                                else
                                        return new EventCollection (this);
@@ -188,7 +195,7 @@
                
                public AttributeSectionCollection Attributes {
                        get {
-                               if ((entry.ContentFlags & 
ContentFlags.HasAttributes) != 0)
+                               if (Wrapped != null && (entry.ContentFlags & 
ContentFlags.HasAttributes) != 0)
                                        return Wrapped.Attributes;
                                else
                                        return new AttributeSectionCollection 
();
@@ -197,7 +204,7 @@
 
                public string Documentation {
                        get {
-                               if ((entry.ContentFlags & 
ContentFlags.HasDocumentation) != 0)
+                               if (Wrapped != null && (entry.ContentFlags & 
ContentFlags.HasDocumentation) != 0)
                                        return Wrapped.Documentation;
                                else
                                        return string.Empty;
@@ -306,7 +313,10 @@
                
                public int CompareTo (object ob)
                {
-                       return Wrapped.CompareTo (ob);
+                       if (Wrapped != null)
+                               return Wrapped.CompareTo (ob);
+                       else
+                               return 1;
                }
        }
 }

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

Reply via email to