Skip to content

Actually show empty-pattern project filter warning

I have discovered this bug thanks to the following GCC warning:

warning: loop variable ‘filter’ of type ‘const KDevelop::Filter&’ binds to a temporary constructed from type ‘const KDevelop::SerializedFilter’ [-Wrange-loop-construct]
  162 |     for (const Filter& filter : filters) {
      |                        ^~~~~~
note: use non-reference type ‘const KDevelop::Filter’ to make the copy explicit or ‘const KDevelop::SerializedFilter&’ to prevent copying

Filter::Filter(const SerializedFilter& filter) prepends "*/" to an empty pattern. So, aside from the inefficiency of constructing a temporary Filter object, the bug prevented displaying the empty-pattern warning.

The project filter validation was implemented in 59ed3308. The very next commit on the next day - a15b683d - changed the type of FilterModel::filters() from Filters to SerializedFilters and introduced the bug. So the empty-pattern warning must have been seen only by its implementer during development testing.

Simply changing the type of the loop variable from Filter& to auto& shows the empty-pattern warning as soon as the user adds a new filter. Prevent this annoyance by not showing the warning if the filter with an empty pattern is newly inserted.

Merge request reports