Index: src/doxygen.cpp
===================================================================
--- src/doxygen.cpp	(Revision 589)
+++ src/doxygen.cpp	(Arbeitskopie)
@@ -1256,100 +1256,60 @@
   ClassSDict::Iterator cli(*Doxygen::classSDict);
   for (cli.toFirst();cli.current();++cli) cli.current()->visited=FALSE;
 
-  int nestingLevel=0;
   bool done=FALSE;
+  int iteration=0;
   while (!done)
   {
-    // iterate over all classes searching for a class with right nesting
-    // level (starting with 0 and going up until no more classes are found)
-    //
-    // we start with all classes that are inside a namespace and then
-    // do the ones outside the namespace to avoid an "internal inconsistency" for the
-    // following:
-    // File A:
-    //    using namespace N;
-    //    class C::P {}
-    // File B:
-    //    namespace N { class C { class P {}; }; }
-    //
-    // If file A is parsed before file B then without it C::P would not be related to N.
     done=TRUE;
-    ClassSDict::Iterator cli(*Doxygen::classSDict);
+    ++iteration;
     ClassDef *cd=0;
-    // first handle any class inside a namespace
     for (cli.toFirst();(cd=cli.current());++cli)
     {
-      QCString c,n;
-      extractNamespaceName(cd->name(),c,n,TRUE);
-      n = stripAnonymousNamespaceScope(n);
-      if (cd->name().contains("::")==nestingLevel && !n.isEmpty())
+      if (!cd->visited)
       {
-        cd->visited=TRUE;
-        //printf("Level=%d processing=%s\n",nestingLevel,cd->name().data());
+        QCString name = stripAnonymousNamespaceScope(cd->name());
+        //printf("processing=%s, iteration=%d\n",cd->name().data(),iteration);
         // also add class to the correct structural context 
         Definition *d = findScopeFromQualifiedName(Doxygen::globalScope,
-                                                 cd->name(),cd->getFileDef());
-        if (d==0) // we didn't find anything, create the scope artificially
-                  // anyway, so we can at least relate scopes properly.
+                                                 name,cd->getFileDef());
+        if (d)
         {
-          Definition *d = buildScopeFromQualifiedName(cd->name(),cd->name().contains("::"));
-          if (d!=cd) // avoid recursion in case of redundant scopes, i.e: namespace N { class N::C {}; }
-                     // for this case doxygen assumes the exitance of a namespace N::N in which C is to be found!
-          {
-            d->addInnerCompound(cd);
-            cd->setOuterScope(d);
-            warn(cd->getDefFileName(),cd->getDefLine(),
-                "Warning: Internal inconsistency: scope for class %s not "
-                "found!",cd->name().data()
-                );
-          }
-        }
-        else
-        {
-          //printf("****** adding %s to scope %s\n",cd->name().data(),d->name().data());
+          //printf("****** adding %s to scope %s in iteration %d\n",cd->name().data(),d->name().data(),iteration);
           d->addInnerCompound(cd);
           cd->setOuterScope(d);
+          cd->visited=TRUE;
+          done=FALSE;
         }
+        //else
+        //{
+        //  printf("****** ignoring %s: scope not (yet) found in iteration %d\n",cd->name().data(),iteration);
+        //}
       }
-      if (!cd->visited) done=FALSE;
     }
-    // and now the same for classes outside any namespace
-    for (cli.toFirst();(cd=cli.current());++cli)
+  }
+
+  //give warnings for unresolved compounds
+  ClassDef *cd=0;
+  for (cli.toFirst();(cd=cli.current());++cli)
+  {
+    if (!cd->visited)
     {
-      if (cd->name().contains("::")==nestingLevel && !cd->visited)
+      QCString name = stripAnonymousNamespaceScope(cd->name());
+      //printf("processing unresolved=%s, iteration=%d\n",cd->name().data(),iteration);
+      /// create the scope artificially
+      // anyway, so we can at least relate scopes properly.
+      Definition *d = buildScopeFromQualifiedName(name,name.contains("::"));
+      if (d!=cd) // avoid recursion in case of redundant scopes, i.e: namespace N { class N::C {}; }
+                 // for this case doxygen assumes the exitance of a namespace N::N in which C is to be found!
       {
-        cd->visited=TRUE;
-        QCString name = stripAnonymousNamespaceScope(cd->name());
-        //printf("Level=%d processing=%s\n",nestingLevel,cd->name().data());
-        // also add class to the correct structural context 
-        Definition *d = findScopeFromQualifiedName(Doxygen::globalScope,
-                                                 name,cd->getFileDef());
-        if (d==0) // we didn't find anything, create the scope artificially
-                  // anyway, so we can at least relate scopes properly.
-        {
-          Definition *d = buildScopeFromQualifiedName(name,name.contains("::"));
-          if (d!=cd) // avoid recursion in case of redundant scopes, i.e: namespace N { class N::C {}; }
-                     // for this case doxygen assumes the exitance of a namespace N::N in which C is to be found!
-          {
-            d->addInnerCompound(cd);
-            cd->setOuterScope(d);
-            warn(cd->getDefFileName(),cd->getDefLine(),
-                "Warning: Internal inconsistency: scope for class %s not "
-                "found while looking in the global scope!",name.data()
-                );
-          }
-        }
-        else
-        {
-          //printf("****** adding %s to scope %s\n",cd->name().data(),d->name().data());
-          d->addInnerCompound(cd);
-          cd->setOuterScope(d);
-        }
+        d->addInnerCompound(cd);
+        cd->setOuterScope(d);
+        warn(cd->getDefFileName(),cd->getDefLine(),
+            "Warning: Internal inconsistency: scope for class %s not "
+            "found!",name.data()
+            );
       }
-      if (!cd->visited) done=FALSE;
     }
-    nestingLevel++;
-    //printf("nestingLevel=%d\n",nestingLevel);
   }
 }
 
