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:
parent
1875c599a4
commit
78c90fe7c6
1 changed files with 8 additions and 2 deletions
|
|
@ -11,6 +11,7 @@
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QRect>
|
#include <QRect>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
Settings *Settings::instance()
|
Settings *Settings::instance()
|
||||||
{
|
{
|
||||||
|
|
@ -117,8 +118,13 @@ QVariant Settings::defaultValue(const QString &key)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key == Core::ScreenName)
|
if (key == Core::ScreenName) {
|
||||||
return QSysInfo::machineHostName();
|
// 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)
|
if (key == Gui::WindowGeometry)
|
||||||
return QRect();
|
return QRect();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue