mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-30 12:32:43 +00:00
Qt: try to fix QString::toDouble locale nonsense
This commit is contained in:
parent
1a00341e6b
commit
afad96a52a
@ -97,7 +97,7 @@ bool try_to_int64(s64* out, std::string_view value, s64 min, s64 max)
|
||||
|
||||
if (result < min || result > max)
|
||||
{
|
||||
if (out) cfg_log.error("cfg::try_to_int64('%s'): out of bounds (%d..%d)", value, min, max);
|
||||
if (out) cfg_log.error("cfg::try_to_int64('%s'): out of bounds (val=%d, min=%d, max=%d)", value, result, min, max);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -140,7 +140,7 @@ bool try_to_uint64(u64* out, std::string_view value, u64 min, u64 max)
|
||||
|
||||
if (result < min || result > max)
|
||||
{
|
||||
if (out) cfg_log.error("cfg::try_to_uint64('%s'): out of bounds (%u..%u)", value, min, max);
|
||||
if (out) cfg_log.error("cfg::try_to_uint64('%s'): out of bounds (val=%u, min=%u, max=%u)", value, result, min, max);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ bool try_to_float(f64* out, std::string_view value, f64 min, f64 max)
|
||||
|
||||
if (result < min || result > max)
|
||||
{
|
||||
if (out) cfg_log.error("cfg::try_to_float('%s'): out of bounds (%f..%f)", value, min, max);
|
||||
if (out) cfg_log.error("cfg::try_to_float('%s'): out of bounds (val=%f, min=%f, max=%f)", value, result, min, max);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -231,7 +231,7 @@ bool cfg::try_to_enum_value(u64* out, decltype(&fmt_class_string<int>::format) f
|
||||
|
||||
if (result > max)
|
||||
{
|
||||
if (out) cfg_log.error("cfg::try_to_enum_value('%s'): out of bounds(0..%u)", value, max);
|
||||
if (out) cfg_log.error("cfg::try_to_enum_value('%s'): out of bounds(val=%u, min=0, max=%u)", value, result, max);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -675,21 +675,27 @@ void emu_settings::EnhanceDoubleSpinBox(QDoubleSpinBox* spinbox, emu_settings_ty
|
||||
}
|
||||
|
||||
const QStringList range = GetSettingOptions(type);
|
||||
bool ok_def, ok_sel, ok_min, ok_max;
|
||||
const std::string def_s = GetSettingDefault(type);
|
||||
const std::string val_s = GetSetting(type);
|
||||
const std::string min_s = sstr(range.first());
|
||||
const std::string max_s = sstr(range.last());
|
||||
|
||||
const double def = qstr(GetSettingDefault(type)).toDouble(&ok_def);
|
||||
const double min = range.first().toDouble(&ok_min);
|
||||
const double max = range.last().toDouble(&ok_max);
|
||||
// cfg::_float range is in s32
|
||||
constexpr s32 min_value = ::std::numeric_limits<s32>::min();
|
||||
constexpr s32 max_value = ::std::numeric_limits<s32>::max();
|
||||
|
||||
f64 val, def, min, max;
|
||||
const bool ok_sel = try_to_float(&val, val_s, min_value, max_value);
|
||||
const bool ok_def = try_to_float(&def, def_s, min_value, max_value);
|
||||
const bool ok_min = try_to_float(&min, min_s, min_value, max_value);
|
||||
const bool ok_max = try_to_float(&max, max_s, min_value, max_value);
|
||||
|
||||
if (!ok_def || !ok_min || !ok_max)
|
||||
{
|
||||
cfg_log.fatal("EnhanceDoubleSpinBox '%s' was used with an invalid type", cfg_adapter::get_setting_name(type));
|
||||
cfg_log.fatal("EnhanceDoubleSpinBox '%s' was used with an invalid type. (val='%s', def='%s', min_s='%s', max_s='%s')", cfg_adapter::get_setting_name(type), val_s, def_s, min_s, max_s);
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string selected = GetSetting(type);
|
||||
double val = qstr(selected).toDouble(&ok_sel);
|
||||
|
||||
if (!ok_sel || val < min || val > max)
|
||||
{
|
||||
cfg_log.error("EnhanceDoubleSpinBox '%s' tried to set an invalid value: %f. Setting to default: %f. Allowed range: [%f, %f]", cfg_adapter::get_setting_name(type), val, def, min, max);
|
||||
|
@ -2646,9 +2646,14 @@ void game_list_frame::PopulateGameList()
|
||||
|
||||
if (game->info.bootable && !game->compat.latest_version.isEmpty())
|
||||
{
|
||||
f64 top_ver = 0.0, app_ver = 0.0;
|
||||
const bool unknown = app_version == localized.category.unknown;
|
||||
const bool ok_app = !unknown && try_to_float(&app_ver, sstr(app_version), ::std::numeric_limits<s32>::min(), ::std::numeric_limits<s32>::max());
|
||||
const bool ok_top = !unknown && try_to_float(&top_ver, sstr(game->compat.latest_version), ::std::numeric_limits<s32>::min(), ::std::numeric_limits<s32>::max());
|
||||
|
||||
// If the app is bootable and the compat database contains info about the latest patch version:
|
||||
// add a hint for available software updates if the app version is unknown or lower than the latest version.
|
||||
if (app_version == localized.category.unknown || game->compat.latest_version.toDouble() > app_version.toDouble())
|
||||
if (unknown || (ok_top && ok_app && top_ver > app_ver))
|
||||
{
|
||||
app_version = tr("%0 (Update available: %1)").arg(app_version, game->compat.latest_version);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user