Bug 415029 - Fails do compile due to Q_FOREACH
Summary: Fails do compile due to Q_FOREACH
Status: RESOLVED FIXED
Alias: None
Product: plasma-pass
Classification: Plasma
Component: General (show other bugs)
Version: 1.1.0
Platform: Debian stable Linux
: NOR normal
Target Milestone: ---
Assignee: Daniel Vrátil
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-12-10 20:33 UTC by Xurxo
Modified: 2020-01-22 13:02 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 1.1.1
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Xurxo 2019-12-10 20:33:11 UTC
SUMMARY

While compiling from scratch, I get this error:

[ 45%] Building CXX object plugin/CMakeFiles/plasmapass.dir/passwordprovider.cpp.o
In file included from /usr/include/KF5/KService/kplugininfo.h:28,
                 from /usr/include/KF5/plasma/package.h:25,
                 from /usr/include/KF5/plasma/pluginloader.h:23,
                 from /usr/include/KF5/Plasma/PluginLoader:1,
                 from /tmp/tmp.3V2PlGdnUp/Descargas/plasma-pass-1.1.0/plugin/passwordprovider.cpp:33:
/usr/include/KF5/KConfigCore/kconfiggroup.h: In member function ‘QList<T> KConfigGroup::readEntry(const char*, const QList<T>&) const’:
/usr/include/KF5/KConfigCore/kconfiggroup.h:734:16: error: expected primary-expression before ‘const’
     Q_FOREACH (const T &value, defaultValue) {
                ^~~~~
/usr/include/KF5/KConfigCore/kconfiggroup.h:734:45: error: expected ‘;’ before ‘{’ token
     Q_FOREACH (const T &value, defaultValue) {
                                             ^~
                                             ;
/usr/include/KF5/KConfigCore/kconfiggroup.h:739:16: error: expected primary-expression before ‘const’
     Q_FOREACH (const QVariant &value, readEntry<QVariantList>(key, data)) {
                ^~~~~
/usr/include/KF5/KConfigCore/kconfiggroup.h:739:5: error: there are no arguments to ‘Q_FOREACH’ that depend on a template parameter, so a declaration of ‘Q_FOREACH’ must be available [-fpermissive]
     Q_FOREACH (const QVariant &value, readEntry<QVariantList>(key, data)) {
     ^~~~~~~~~
/usr/include/KF5/KConfigCore/kconfiggroup.h:739:5: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
/usr/include/KF5/KConfigCore/kconfiggroup.h:739:74: error: expected ‘;’ before ‘{’ token
     Q_FOREACH (const QVariant &value, readEntry<QVariantList>(key, data)) {
                                                                          ^~
                                                                          ;
/usr/include/KF5/KConfigCore/kconfiggroup.h: In member function ‘void KConfigGroup::writeEntry(const char*, const QList<T>&, KConfigBase::WriteConfigFlags)’:
/usr/include/KF5/KConfigCore/kconfiggroup.h:760:16: error: expected primary-expression before ‘const’
     Q_FOREACH (const T &value, list) {
                ^~~~~
/usr/include/KF5/KConfigCore/kconfiggroup.h:760:37: error: expected ‘;’ before ‘{’ token
     Q_FOREACH (const T &value, list) {
                                     ^~
                                     ;
make[2]: *** [plugin/CMakeFiles/plasmapass.dir/build.make:126: plugin/CMakeFiles/plasmapass.dir/passwordprovider.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:596: plugin/CMakeFiles/plasmapass.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

STEPS TO REPRODUCE
1. Download and extract 1.1.0 tar
2. Run cmake
3. Run make

OBSERVED RESULT
A compiler error

EXPECTED RESULT
A compiled binary

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Debian GNU/Linux "Buster" 10.2
(available in About System)
KDE Plasma Version: 5.14.5.1
KDE Frameworks Version: 5.54.0
Qt Version: 5.11.3

ADDITIONAL INFORMATION

Investigating the issue, I found the following commit:
https://cgit.kde.org/plasma-pass.git/commit/?id=d5999a0b6a7c3d1d126cd6afb25f38e573aa7d57

There, it claims Q_FOREACH is not needed, and sets a flag to disable it.
Looks like the project itself doesn't use Q_FOREACH, but an indirect import does.
I removed the line:
add_definitions(-DQT_NO_FOREACH)
from the "CMakeLists.txt" file and everything compiled fine.
Comment 1 Daniel Vrátil 2020-01-22 13:02:22 UTC
Git commit 2667be0cd4343af4b2300473e2026bf9d444c56a by Daniel Vrátil.
Committed on 22/01/2020 at 07:45.
Pushed by dvratil into branch 'master'.

Bump minimum required Qt and Frameworks

PP wouldn't compile against older Frameworks with disabled
deprecated Qt functions and Q_FOREACH.
FIXED-IN: 1.1.1

M  +2    -2    CMakeLists.txt

https://commits.kde.org/plasma-pass/2667be0cd4343af4b2300473e2026bf9d444c56a