Blob Blame History Raw
diff -ur doxygen-1.9.2.orig/src/dirdef.cpp doxygen-1.9.2/src/dirdef.cpp
--- doxygen-1.9.2.orig/src/dirdef.cpp	2021-08-17 19:10:43.000000000 +0200
+++ doxygen-1.9.2/src/dirdef.cpp	2021-09-12 21:25:51.878853938 +0200
@@ -47,7 +47,7 @@
     virtual bool isLinkableInProject() const;
     virtual bool isLinkable() const;
     virtual QCString displayName(bool=TRUE) const { return m_dispName; }
-    virtual const QCString &shortName() const { return m_shortName; }
+    virtual const QCString shortName() const { return m_shortName; }
     virtual void addSubDir(DirDef *subdir);
     virtual const FileList &getFiles() const { return m_fileList; }
     virtual void addFile(const FileDef *fd);
@@ -66,6 +66,7 @@
     virtual void setDiskName(const QCString &name) { m_diskName = name; }
     virtual void sort();
     virtual void setParent(DirDef *parent);
+    virtual void setDirCount(int count);
     virtual void setLevel();
     virtual void addUsesDependency(const DirDef *usedDir,const FileDef *srcFd,
                                    const FileDef *dstFd,bool inherited);
@@ -92,7 +93,7 @@
     QCString m_shortName;
     QCString m_diskName;
     FileList m_fileList;                 // list of files in the group
-    int m_dirCount;
+    int m_dirCount = -1;
     int m_level;
     DirDef *m_parent;
     UsedDirLinkedMap m_usedDirs;
@@ -107,8 +108,6 @@
 //----------------------------------------------------------------------
 // method implementation
 
-static int g_dirCount=0;
-
 DirDefImpl::DirDefImpl(const QCString &path) : DefinitionMixin(path,1,1,path)
 {
   bool fullPathNames = Config_getBool(FULL_PATH_NAMES);
@@ -132,7 +131,6 @@
     m_dispName = m_dispName.left(m_dispName.length()-1);
   }
 
-  m_dirCount   = g_dirCount++;
   m_level=-1;
   m_parent=0;
 }
@@ -163,6 +161,11 @@
    m_parent=p;
 }
 
+void DirDefImpl::setDirCount(int count)
+{
+  m_dirCount=count;
+}
+
 void DirDefImpl::addFile(const FileDef *fd)
 {
   m_fileList.push_back(fd);
@@ -993,7 +996,6 @@
   {
     for (const auto &fd : *fn)
     {
-      //printf("buildDirectories %s\n",qPrint(fd->name()));
       if (fd->getReference().isEmpty())
       {
         DirDef *dir;
@@ -1038,7 +1040,24 @@
   std::sort(Doxygen::dirLinkedMap->begin(),
             Doxygen::dirLinkedMap->end(),
             [](const auto &d1,const auto &d2)
-            { return qstricmp(d1->shortName(),d2->shortName()) < 0; });
+            {
+              QCString s1 = d1->shortName(), s2 = d2->shortName();
+              int i = qstricmp(s1,s2);
+              if (i==0) // if sort name are equal, sort on full path
+              {
+                QCString n1 = d1->name(), n2 = d2->name();
+                int n = qstricmp(n1,n2);
+                return n < 0;
+              }
+              return i < 0;
+            });
+
+  // set the directory count identifier
+  int dirCount=0;
+  for (const auto &dir : *Doxygen::dirLinkedMap)
+  {
+    dir->setDirCount(dirCount++);
+  }
 
   computeCommonDirPrefix();
 }
diff -ur doxygen-1.9.2.orig/src/dirdef.h doxygen-1.9.2/src/dirdef.h
--- doxygen-1.9.2.orig/src/dirdef.h	2021-05-12 20:51:20.000000000 +0200
+++ doxygen-1.9.2/src/dirdef.h	2021-09-12 21:25:42.394830066 +0200
@@ -95,7 +95,7 @@
     virtual bool isLinkableInProject() const = 0;
     virtual bool isLinkable() const = 0;
     virtual QCString displayName(bool=TRUE) const = 0;
-    virtual const QCString &shortName() const = 0;
+    virtual const QCString shortName() const = 0;
     virtual void addSubDir(DirDef *subdir) = 0;
     virtual const FileList &getFiles() const = 0;
     virtual void addFile(const FileDef *fd) = 0;
@@ -115,6 +115,7 @@
     virtual void writeTagFile(TextStream &t) = 0;
 
     virtual void setDiskName(const QCString &name) = 0;
+    virtual void setDirCount(int count) = 0;
     virtual void sort() = 0;
     virtual void setParent(DirDef *parent) = 0;
     virtual void setLevel() = 0;