aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/generator
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2024-04-17 09:34:37 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2024-04-17 19:09:31 +0200
commit1f1085a209bddd38e84c638686017061ca1f781b (patch)
tree586b4701e8f4f15acedf4cf6c870298e6a73d3a7 /sources/shiboken6/generator
parent87b473e1648ab793b69d040e77fecf8a2ecee7b1 (diff)
Documentation: Ensure deterministic order of function overloads
Sort by argument count in addition to name to put the simplest overloads first and use stable sort to get the order of the declaration. Pick-to: 6.7 Change-Id: Ib02fce2c03865713d2d4c457e578a668f04f1ca4 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Diffstat (limited to 'sources/shiboken6/generator')
-rw-r--r--sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp
index 1103cef29..2797ff254 100644
--- a/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp
+++ b/sources/shiboken6/generator/qtdoc/qtdocgenerator.cpp
@@ -147,8 +147,13 @@ static bool shouldSkip(const AbstractMetaFunctionCPtr &func)
static bool functionSort(const AbstractMetaFunctionCPtr &func1, const AbstractMetaFunctionCPtr &func2)
{
const bool ctor1 = func1->isConstructor();
- const bool ctor2 = func2->isConstructor();
- return ctor1 != ctor2 ? ctor1 : func1->name() < func2->name();
+ if (ctor1 != func2->isConstructor())
+ return ctor1;
+ const QString &name1 = func1->name();
+ const QString &name2 = func2->name();
+ if (name1 != name2)
+ return name1 < name2;
+ return func1->arguments().size() < func2->arguments().size();
}
static inline QVersionNumber versionOf(const TypeEntryCPtr &te)
@@ -1421,7 +1426,7 @@ GeneratorDocumentation
std::remove_copy_if(allFunctions.cbegin(), allFunctions.cend(),
std::back_inserter(result.allFunctions), shouldSkip);
- std::sort(result.allFunctions.begin(), result.allFunctions.end(), functionSort);
+ std::stable_sort(result.allFunctions.begin(), result.allFunctions.end(), functionSort);
for (const auto &func : std::as_const(result.allFunctions)) {
if (func->isStatic())