Skip to content
Commit f56cdda5 authored by Igor Kushnir's avatar Igor Kushnir
Browse files

Work around QDir::match() behavior change in Qt 5.12.0

QDir::match() migrated to QRegularExpression in Qt 5.12.0. In the new
implementation asterisk in a wildcard no longer matches path separators.

This caused two bugs in KDevelop:
1. kdev_format_source rejects input files if the 'format_sources' file
  is not located in the same directory as the target file.
2. Exclude filter in Find/Replace in Files has no effect (unless the
  user specifies almost complete paths in the format supported by Bash
  Filename Expansion with the globstar shell option disabled).

Note that Files (aka `include`) filter in Find/Replace in Files is
unaffected by the behavior change because in its code a filename rather
than a path is passed as the second argument to QDir::match().

WildcardHelpers can migrate to
QRegularExpression::wildcardToRegularExpression() once we require
Qt 5.12.1 or later. This function was added in Qt 5.12.0 and started
anchoring wildcard pattern in Qt 5.12.1.

Ideally support for globstar (**) in glob patterns should be added to
QRegularExpression::wildcardToRegularExpression() and to QDir::match().
In that case WildcardHelpers could be eliminated and QDir::match() could
be used again.

If globstar support is not added to
QRegularExpression::wildcardToRegularExpression(), WildcardHelpers can
port away from QRegExp, for example, by replacing `starEscape` (see the
definition of wildcardToRegularExpression()) with ".*" in the value
returned by wildcardToRegularExpression() and passing
DotMatchesEverythingOption to QRegularExpression constructor.

When we port away from QRegExp, we can change the syntax of
format_sources and possibly Exclude filter to match Bash globstar
syntax or perhaps some other new Qt wildcard syntax. Alternatively, we
can process user-provided wildcard patterns before and/or after passing
them to wildcardToRegularExpression() so as to preserve our syntax.

BUG: 409222, 417628
FIXED-IN: 5.5.1
parent 80409842
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment