mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 08:35:20 +02:00
Fix issue Minetest crash when custom font path is not exist
We try to use default fallback for both mono and main font when custom font path is not exist. This way, if Minetest is not corrupted, we could avoid crash.
This commit is contained in:
committed by
sfan5
parent
d693f95fc3
commit
9526c68699
@@ -361,6 +361,18 @@ const SettingsEntry &Settings::getEntry(const std::string &name) const
|
||||
}
|
||||
|
||||
|
||||
const SettingsEntry &Settings::getEntryDefault(const std::string &name) const
|
||||
{
|
||||
MutexAutoLock lock(m_mutex);
|
||||
|
||||
SettingEntries::const_iterator n;
|
||||
if ((n = m_defaults.find(name)) == m_defaults.end()) {
|
||||
throw SettingNotFoundException("Setting [" + name + "] not found.");
|
||||
}
|
||||
return n->second;
|
||||
}
|
||||
|
||||
|
||||
Settings *Settings::getGroup(const std::string &name) const
|
||||
{
|
||||
const SettingsEntry &entry = getEntry(name);
|
||||
@@ -379,6 +391,15 @@ const std::string &Settings::get(const std::string &name) const
|
||||
}
|
||||
|
||||
|
||||
const std::string &Settings::getDefault(const std::string &name) const
|
||||
{
|
||||
const SettingsEntry &entry = getEntryDefault(name);
|
||||
if (entry.is_group)
|
||||
throw SettingNotFoundException("Setting [" + name + "] is a group.");
|
||||
return entry.value;
|
||||
}
|
||||
|
||||
|
||||
bool Settings::getBool(const std::string &name) const
|
||||
{
|
||||
return is_yes(get(name));
|
||||
@@ -571,6 +592,17 @@ bool Settings::getEntryNoEx(const std::string &name, SettingsEntry &val) const
|
||||
}
|
||||
|
||||
|
||||
bool Settings::getEntryDefaultNoEx(const std::string &name, SettingsEntry &val) const
|
||||
{
|
||||
try {
|
||||
val = getEntryDefault(name);
|
||||
return true;
|
||||
} catch (SettingNotFoundException &e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Settings::getGroupNoEx(const std::string &name, Settings *&val) const
|
||||
{
|
||||
try {
|
||||
@@ -593,6 +625,17 @@ bool Settings::getNoEx(const std::string &name, std::string &val) const
|
||||
}
|
||||
|
||||
|
||||
bool Settings::getDefaultNoEx(const std::string &name, std::string &val) const
|
||||
{
|
||||
try {
|
||||
val = getDefault(name);
|
||||
return true;
|
||||
} catch (SettingNotFoundException &e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Settings::getFlag(const std::string &name) const
|
||||
{
|
||||
try {
|
||||
|
Reference in New Issue
Block a user