fix: Crash caused by hostnames with invalid characters returned by machine name.
fixes: #9006 Only cleans the hostname if the system is using the default Replace Spaces with _ Remove any other non word characters
This commit is contained in:
committed by
Chris Rizzitello
parent
1875c599a4
commit
78c90fe7c6
@ -11,6 +11,7 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QFile>
|
||||
#include <QRect>
|
||||
#include <QRegularExpression>
|
||||
|
||||
Settings *Settings::instance()
|
||||
{
|
||||
@ -117,8 +118,13 @@ QVariant Settings::defaultValue(const QString &key)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (key == Core::ScreenName)
|
||||
return QSysInfo::machineHostName();
|
||||
if (key == Core::ScreenName) {
|
||||
// The localhost name can contain spaces and non word characters
|
||||
QString name = QSysInfo::machineHostName().simplified();
|
||||
name.replace(QLatin1String(" "), QStringLiteral("_"));
|
||||
name.replace(QRegularExpression(QLatin1String("\\W")), QLatin1String(""));
|
||||
return name;
|
||||
}
|
||||
|
||||
if (key == Gui::WindowGeometry)
|
||||
return QRect();
|
||||
|
||||
Reference in New Issue
Block a user