From c430a25ab6b3ba358cc42715eec6223a7de6e2e1 Mon Sep 17 00:00:00 2001 From: Allen Winter Date: Tue, 8 Apr 2025 15:54:14 -0400 Subject: [PATCH] cfg/kde.cfg - add more KDE macros that are widely used --- cfg/kde.cfg | 5 +++++ test/CMakeLists.txt | 2 +- test/cfg/kde.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++- test/cfg/runtests.sh | 2 +- 4 files changed, 51 insertions(+), 3 deletions(-) diff --git a/cfg/kde.cfg b/cfg/kde.cfg index 7d18998a29f..1131d5e0c50 100644 --- a/cfg/kde.cfg +++ b/cfg/kde.cfg @@ -20,6 +20,11 @@ + + + + + diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 467e6e95e4e..3b516f38965 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -148,7 +148,7 @@ if (BUILD_TESTS) add_cfg(gnu.c ADD_LIBRARY posix) add_cfg(googletest.cpp) add_cfg(gtk.c) - add_cfg(kde.cpp) + add_cfg(kde.cpp ADD_LIBRARY qt) add_cfg(libcurl.c) add_cfg(libsigc++.cpp) add_cfg(lua.c) diff --git a/test/cfg/kde.cpp b/test/cfg/kde.cpp index 069aa5d2d48..71533ca781f 100644 --- a/test/cfg/kde.cpp +++ b/test/cfg/kde.cpp @@ -2,7 +2,7 @@ // Test library configuration for kde.cfg // // Usage: -// $ cppcheck --check-library --library=kde --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/kde.cpp +// $ cppcheck --check-library --library=kde --library=qt --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/kde.cpp // => // No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 // @@ -11,6 +11,7 @@ #include #include #include +#include class k_global_static_testclass1 {}; K_GLOBAL_STATIC(k_global_static_testclass1, k_global_static_testinstance1); @@ -41,3 +42,45 @@ void i18n_test() (void)xi18nc("Text", "Context"); (void)ki18nc("Text", "Context"); } + +class PluginWithoutMetaData : public QObject +{ + Q_OBJECT +public: + // Add a default arg to make sure we do not get an ambiguity compiler error + explicit PluginWithoutMetaData(const QObject *, const QVariantList &args = {}) + : QObject() + { + Q_UNUSED(args) + }; +}; + +K_PLUGIN_CLASS(PluginWithoutMetaData) + +class StaticSimplePluginClass : public QObject +{ + Q_OBJECT + +public: + // Next to the assertion below, ensure that we have no ambiguity! + explicit StaticSimplePluginClass(QObject *parent, const QString &data = {}) + : QObject(parent) + { + // We have added a default arg, but KPluginFactory should still provide the valid metadata instead of the default one + data = QString("foo"); + } +}; +K_PLUGIN_CLASS_WITH_JSON(StaticSimplePluginClass, "data/jsonplugin.json") + +class ClipboardPlugin : public Purpose::PluginBase +{ + Q_OBJECT +public: + using PluginBase::PluginBase; + Purpose::Job *createJob() const override + { + return new ClipboardJob(nullptr); + } +}; + +K_PLUGIN_FACTORY_WITH_JSON(Clipboard, "clipboardplugin.json", foo) diff --git a/test/cfg/runtests.sh b/test/cfg/runtests.sh index 1ff731abe16..bfc5e8f04f3 100755 --- a/test/cfg/runtests.sh +++ b/test/cfg/runtests.sh @@ -507,7 +507,7 @@ function check_file { kde.cpp) # TODO: "kde-4config" is no longer commonly available in recent distros #kde_fn - "${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" "${DIR}""$f" + "${CPPCHECK}" "${CPPCHECK_OPT[@]}" --library="$lib" --library=qt "${DIR}""$f" ;; libcurl.c) libcurl_fn