diff options
Diffstat (limited to 'logic')
-rw-r--r-- | logic/state.hpp | 2 | ||||
-rw-r--r-- | logic/work.cpp | 12 | ||||
-rw-r--r-- | logic/work.hpp | 8 |
3 files changed, 14 insertions, 8 deletions
diff --git a/logic/state.hpp b/logic/state.hpp index 4e021949..f5892557 100644 --- a/logic/state.hpp +++ b/logic/state.hpp @@ -13,7 +13,6 @@ using namespace options; #include "api/plugin-support.hpp" #include "main-settings.hpp" #include "mappings.hpp" -#include "selected-libraries.hpp" #include "work.hpp" #include <vector> #include <QString> @@ -25,7 +24,6 @@ struct State pose(std::vector<axis_opts*>{&s.a_x, &s.a_y, &s.a_z, &s.a_yaw, &s.a_pitch, &s.a_roll}) {} Modules modules; - SelectedLibraries libs; main_settings s; Mappings pose; mem<Work> work; diff --git a/logic/work.cpp b/logic/work.cpp index ebac4c39..102b859e 100644 --- a/logic/work.cpp +++ b/logic/work.cpp @@ -60,12 +60,11 @@ std::shared_ptr<TrackLogger> Work::make_logger(main_settings &s) } -Work::Work(Mappings& m, SelectedLibraries& libs, WId handle) : - libs(libs), +Work::Work(Mappings& m, QFrame* frame, mem<dylib>& tracker_, mem<dylib>& filter_, mem<dylib>& proto_) : + libs(frame, tracker_, filter_, proto_), logger(make_logger(s)), tracker(std::make_shared<Tracker>(m, libs, *logger)), sc(std::make_shared<Shortcuts>()), - handle(handle), keys { key_tuple(s.key_center1, [&](bool) -> void { tracker->center(); }, true), key_tuple(s.key_center2, [&](bool) -> void { tracker->center(); }, true), @@ -83,6 +82,8 @@ Work::Work(Mappings& m, SelectedLibraries& libs, WId handle) : key_tuple(s.key_zero_press2, [&](bool x) -> void { tracker->set_zero(x); }, false), } { + if (!is_ok()) + return; reload_shortcuts(); tracker->start(); } @@ -92,6 +93,11 @@ void Work::reload_shortcuts() sc->reload(keys); } +bool Work::is_ok() const +{ + return libs.correct; +} + Work::~Work() { // order matters, otherwise use-after-free -sh diff --git a/logic/work.hpp b/logic/work.hpp index b614c580..ff0524bd 100644 --- a/logic/work.hpp +++ b/logic/work.hpp @@ -14,6 +14,8 @@ #include "shortcuts.h" #include "export.hpp" #include "tracklogger.hpp" +#include "logic/selected-libraries.hpp" +#include "api/plugin-support.hpp" #include <QObject> #include <QFrame> @@ -27,16 +29,16 @@ struct OPENTRACK_LOGIC_EXPORT Work using fn_t = std::function<void(bool)>; using key_tuple = std::tuple<key_opts&, fn_t, bool>; main_settings s; // tracker needs settings, so settings must come before it - SelectedLibraries& libs; std::shared_ptr<TrackLogger> logger; // must come before tracker, since tracker depends on it + SelectedLibraries libs; // idem std::shared_ptr<Tracker> tracker; std::shared_ptr<Shortcuts> sc; - WId handle; std::vector<key_tuple> keys; - Work(Mappings& m, SelectedLibraries& libs, WId handle); + Work(Mappings& m, QFrame* frame, mem<dylib>& tracker, mem<dylib>& filter, mem<dylib>& proto); ~Work(); void reload_shortcuts(); + bool is_ok() const; private: static std::shared_ptr<TrackLogger> make_logger(main_settings &s); |