summaryrefslogtreecommitdiffhomepage
path: root/migration/20160906_00-mappings.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-05-06 13:15:16 +0200
committerStanislaw Halik <sthalik@misaki.pl>2017-05-10 11:19:22 +0200
commit87c09c0ab5e1334e9877ee6fd7adeb1eb70d5929 (patch)
tree3f407f9d0fc947427729913cf60e2e5f9b962ce0 /migration/20160906_00-mappings.cpp
parent604914db84d0468c6c8d04dfe6491e3c15b670f7 (diff)
options: don't create QSettings all the time
Update usages.
Diffstat (limited to 'migration/20160906_00-mappings.cpp')
-rw-r--r--migration/20160906_00-mappings.cpp40
1 files changed, 18 insertions, 22 deletions
diff --git a/migration/20160906_00-mappings.cpp b/migration/20160906_00-mappings.cpp
index 58674843..a5184825 100644
--- a/migration/20160906_00-mappings.cpp
+++ b/migration/20160906_00-mappings.cpp
@@ -36,31 +36,30 @@ struct mappings_from_2_3_0_rc11 : migration
"rz", "rz_alt",
};
- std::shared_ptr<QSettings> settings_ = options::group::ini_file();
- QSettings& settings(*settings_);
-
- for (const char* name : names)
- {
- QList<QPointF> points;
+ return group::with_settings_object([&](QSettings& settings) {
+ for (const char* name : names)
+ {
+ QList<QPointF> points;
- settings.beginGroup(QString("Curves-%1").arg(name));
+ settings.beginGroup(QString("Curves-%1").arg(name));
- const int max = settings.value("point-count", 0).toInt();
+ 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());
+ 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(new_point);
+ }
- settings.endGroup();
+ settings.endGroup();
- ret.append(points);
- }
+ ret.append(points);
+ }
- return ret;
+ return ret;
+ });
}
QString unique_date() const override { return "20160909_00"; }
@@ -94,9 +93,6 @@ struct mappings_from_2_3_0_rc11 : migration
const QList<QList<QPointF>> old_mappings = get_old_splines();
Mappings m = get_new_mappings();
- std::shared_ptr<QSettings> s_ = options::group::ini_file();
- QSettings& s = *s_;
-
for (int i = 0; i < 12; i++)
{
spline& spl = (i % 2) == 0 ? m(i / 2).spline_main : m(i / 2).spline_alt;
@@ -104,7 +100,7 @@ struct mappings_from_2_3_0_rc11 : migration
const QList<QPointF>& points = old_mappings[i];
for (const QPointF& pt : points)
spl.add_point(pt);
- spl.save(s);
+ spl.save();
}
}
};