summaryrefslogtreecommitdiffhomepage
path: root/spline-widget/spline-widget.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-08-21 17:34:00 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-08-23 00:05:15 +0200
commitd6dffea39f3546e29a0cf1689d7d83b84dedfd9d (patch)
tree4f1f79d63631aae845dd130cb0b608540dec8fad /spline-widget/spline-widget.cpp
parent550390d6d2f4e7ea21f6fa407e3b054a8ac12fd4 (diff)
spline-widget: multiple fixes
- add missing locking - bundle and settings ptr are never null following initialization; sentinel objects get created if there's no bundle, thus don't branch outside initialization functions. the sentinel object doesn't load or save to the .ini file - connect spline refresh to any bundle change - connect spline widget refresh to spline refresh - few caveat comments - spline_widget::setConfig now only takes the spline as argument, eliminating most of the complex logic there - clarify spline::set_bundle vs newly introduced spline::recompute
Diffstat (limited to 'spline-widget/spline-widget.cpp')
-rw-r--r--spline-widget/spline-widget.cpp38
1 files changed, 22 insertions, 16 deletions
diff --git a/spline-widget/spline-widget.cpp b/spline-widget/spline-widget.cpp
index 85477ba7..ce16f7be 100644
--- a/spline-widget/spline-widget.cpp
+++ b/spline-widget/spline-widget.cpp
@@ -10,6 +10,8 @@
#include <QPaintEvent>
#include <QPen>
#include <QPixmap>
+#include <QList>
+#include <QPointF>
#include <cmath>
#include <algorithm>
@@ -26,23 +28,27 @@ spline_widget::spline_widget(QWidget *parent) :
setMouseTracking(true);
}
-void spline_widget::setConfig(spline* config, bundle b)
+void spline_widget::setConfig(spline* spl)
{
- if (config && config->get_bundle() && config->get_bundle() != b)
+ if (spl != _config)
{
- QObject::disconnect(connection);
- connection = QMetaObject::Connection();
- }
+ if (connection)
+ {
+ QObject::disconnect(connection);
+ //connection = QMetaObject::Connection();
+ }
- if (config && config->get_bundle() != b)
- config->set_bundle(b);
- _config = config;
- if (b)
- connection = connect(b.get(), &bundle_type::reloading,
- this, &spline_widget::reload_spline,
- Qt::QueuedConnection);
- update_range();
- update();
+ if (spl)
+ {
+ spline::settings& s = spl->get_settings();
+ connection = connect(&s, &spline::settings::recomputed,
+ this, [this]() { reload_spline(); },
+ Qt::QueuedConnection);
+ }
+
+ _config = spl;
+ update_range();
+ }
}
void spline_widget::set_preview_only(bool val)
@@ -417,9 +423,9 @@ void spline_widget::mouseReleaseEvent(QMouseEvent *e)
void spline_widget::reload_spline()
{
- if (_config && _config->get_bundle() != nullptr)
+ if (_config)
{
- _config->set_bundle(_config->get_bundle());
+ // don't recompute here as the value's just been recomputed
update_range();
}
}