Const'ify two static variables

Even though the variables are local, they were exposed as writable
references. Turning those variables into constants and propagating the
constness prevents accidental modifications.

Change-Id: If874ae4995fb95434ad28da6682c980f90666061
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Bernhard Beschow
2017-11-11 12:42:01 +01:00
parent d76c869e56
commit 88839a8cfa
3 changed files with 7 additions and 7 deletions

View File

@@ -845,9 +845,9 @@ bool PluginSpecPrivate::provides(const QString &pluginName, const QString &plugi
/*! /*!
\internal \internal
*/ */
QRegExp &PluginSpecPrivate::versionRegExp() const QRegExp &PluginSpecPrivate::versionRegExp()
{ {
static QRegExp reg(QLatin1String("([0-9]+)(?:[.]([0-9]+))?(?:[.]([0-9]+))?(?:_([0-9]+))?")); static const QRegExp reg(QLatin1String("([0-9]+)(?:[.]([0-9]+))?(?:[.]([0-9]+))?(?:_([0-9]+))?"));
return reg; return reg;
} }
/*! /*!

View File

@@ -111,7 +111,7 @@ private:
PluginSpec *q; PluginSpec *q;
bool reportError(const QString &err); bool reportError(const QString &err);
static QRegExp &versionRegExp(); static const QRegExp &versionRegExp();
}; };
} // namespace Internal } // namespace Internal

View File

@@ -46,16 +46,16 @@ namespace Utils {
// Naming a file like a device name will break on Windows, even if it is // Naming a file like a device name will break on Windows, even if it is
// "com1.txt". Since we are cross-platform, we generally disallow such file // "com1.txt". Since we are cross-platform, we generally disallow such file
// names. // names.
static QRegExp &windowsDeviceNoSubDirPattern() static const QRegExp &windowsDeviceNoSubDirPattern()
{ {
static QRegExp rc(QLatin1String(WINDOWS_DEVICES), Qt::CaseInsensitive); static const QRegExp rc(QLatin1String(WINDOWS_DEVICES), Qt::CaseInsensitive);
QTC_ASSERT(rc.isValid(), return rc); QTC_ASSERT(rc.isValid(), return rc);
return rc; return rc;
} }
static QRegExp &windowsDeviceSubDirPattern() static const QRegExp &windowsDeviceSubDirPattern()
{ {
static QRegExp rc(QLatin1String(".*[/\\\\](" WINDOWS_DEVICES ")"), Qt::CaseInsensitive); static const QRegExp rc(QLatin1String(".*[/\\\\](" WINDOWS_DEVICES ")"), Qt::CaseInsensitive);
QTC_ASSERT(rc.isValid(), return rc); QTC_ASSERT(rc.isValid(), return rc);
return rc; return rc;
} }