summaryrefslogtreecommitdiffhomepage
path: root/migration/20160906_00-mappings.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'migration/20160906_00-mappings.cpp')
-rw-r--r--migration/20160906_00-mappings.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/migration/20160906_00-mappings.cpp b/migration/20160906_00-mappings.cpp
index 567fbdcb..2bc00084 100644
--- a/migration/20160906_00-mappings.cpp
+++ b/migration/20160906_00-mappings.cpp
@@ -18,6 +18,8 @@
#include <QDebug>
+using namespace options;
+using namespace options::globals;
using namespace migrations;
static const char* const old_names[] =
@@ -43,22 +45,22 @@ static QList<QList<QPointF>> get_old_splines()
{
QList<QList<QPointF>> ret;
- return group::with_settings_object([&](QSettings& settings) {
+ return with_settings_object([&](QSettings& settings) {
for (const char* name : old_names)
{
+ const int max = settings.value("point-count", 0).toInt();
+
+ if (max < 0 || max > 1 << 16)
+ return ret;
+
QList<QPointF> points;
+ points.reserve(max);
settings.beginGroup(QString("Curves-%1").arg(name));
- const int max = settings.value("point-count", 0).toInt();
-
for (int i = 0; i < max; i++)
- {
- QPointF new_point(settings.value(QString("point-%1-x").arg(i), 0).toDouble(),
- settings.value(QString("point-%1-y").arg(i), 0).toDouble());
-
- points.append(new_point);
- }
+ points.append({ settings.value(QString("point-%1-x").arg(i), 0).toDouble(),
+ settings.value(QString("point-%1-y").arg(i), 0).toDouble() });
settings.endGroup();
@@ -85,7 +87,7 @@ struct mappings_from_2_3_0_rc11 : migration
// run only if old splines exist
for (const QList<QPointF>& points : get_old_splines())
- if (points.size())
+ if (!points.empty())
return true;
}
@@ -95,7 +97,7 @@ struct mappings_from_2_3_0_rc11 : migration
void run() override
{
- group::with_settings_object([this](QSettings&) {
+ with_settings_object([](QSettings&) {
const QList<QList<QPointF>> old_mappings = get_old_splines();
for (int i = 0; i < 12; i++)
@@ -111,4 +113,4 @@ struct mappings_from_2_3_0_rc11 : migration
}
};
-OPENTRACK_MIGRATION(mappings_from_2_3_0_rc11);
+OPENTRACK_MIGRATION(mappings_from_2_3_0_rc11)