Bug 509891 - Qt6 build compatibility issue: Q_FOREACH macro still used
Summary: Qt6 build compatibility issue: Q_FOREACH macro still used
Status: RESOLVED NOT A BUG
Alias: None
Product: kde
Classification: I don't know
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Unassigned bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-09-24 20:34 UTC by jshand2013
Modified: 2025-09-24 20:59 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jshand2013 2025-09-24 20:34:14 UTC
Operating System: openSUSE Tumbleweed 20250923
KDE Plasma Version: 6.4.5
KDE Frameworks Version: 6.18.0
Qt Version: 6.9.2
Kernel Version: 6.16.8-1-default (64-bit)
Graphics Platform: Wayland
Processors: 12 × Intel® Core™ 7 150U
Memory: 16 GiB of RAM (15.3 GiB usable)
Graphics Processor: Intel® Graphics
Manufacturer: Dell Inc.
Product Name: Inspiron 16 5640

Qt6 build compatibility issue: Q_FOREACH macro still used

**Severity:** Medium  
**Area:** Server / SearchManager  

## Description
Code targets Qt6 (`find_package(Qt6...)`), but still uses `Q_FOREACH` macro in `SearchManager`. This macro was removed in Qt6; compilation may rely on compat headers or fail on some setups.

## Evidence
/mnt/data/akonadi_extracted/akonadi/src/server/search/searchmanager.cpp lines 96–101:

```
  96|      * and causes crash on Akonadi shutdown (below main). Keeping the plugins
  97|      * loaded is not really a big issue as this is only invoked on server shutdown
  98|      * anyway, so we are not leaking any memory.
  99|     Q_FOREACH (QPluginLoader *loader, mPluginLoaders) {
 100|         loader->unload();
 101|         delete loader;
```

## Steps to Reproduce
1. Build Akonadi against a strict Qt6 environment without Qt5Compat headers.
2. Compilation errors occur at `Q_FOREACH` usage.

## Expected Behavior
Code should compile cleanly under Qt6 without deprecated Qt5 macros.

## Actual Behavior
`Q_FOREACH` persists in codebase.

## Suggested Fix / Next Steps
- Replace `Q_FOREACH` with C++11 range-based for loop: `for (auto *loader : mPluginLoaders) { ... }`.
- Remove any remaining uses of `foreach`/`Q_FOREACH` macros.
Comment 1 Nate Graham 2025-09-24 20:59:12 UTC
Please don't copy-paste the output of code "analysis" from ChatGPT or another AI. It isn't actionable. Submitting merge requests to change these things would be helpful, but bug reports pointing them out isn't.