Skip to content
  • Igor Kushnir's avatar
    Actually show empty-pattern project filter error · bbf021c6
    Igor Kushnir authored
    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 error.
    
    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 error 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 error as soon as the user adds a new filter.
    Prevent this annoyance by not rechecking filters when a row is inserted
    (and when a row is moved, for good measure, to skip useless work).
    bbf021c6