From 6f69cdc4305740ed9f54b296a62a8c59ff98da0c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 23 Feb 2017 06:06:20 +0100 Subject: logic, gui: move selected-libraries to struct work --- logic/state.hpp | 2 -- logic/work.cpp | 12 +++++++++--- logic/work.hpp | 8 +++++--- 3 files changed, 14 insertions(+), 8 deletions(-) (limited to 'logic') 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 #include @@ -25,7 +24,6 @@ struct State pose(std::vector{&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; 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 Work::make_logger(main_settings &s) } -Work::Work(Mappings& m, SelectedLibraries& libs, WId handle) : - libs(libs), +Work::Work(Mappings& m, QFrame* frame, mem& tracker_, mem& filter_, mem& proto_) : + libs(frame, tracker_, filter_, proto_), logger(make_logger(s)), tracker(std::make_shared(m, libs, *logger)), sc(std::make_shared()), - 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 #include @@ -27,16 +29,16 @@ struct OPENTRACK_LOGIC_EXPORT Work using fn_t = std::function; using key_tuple = std::tuple; main_settings s; // tracker needs settings, so settings must come before it - SelectedLibraries& libs; std::shared_ptr logger; // must come before tracker, since tracker depends on it + SelectedLibraries libs; // idem std::shared_ptr tracker; std::shared_ptr sc; - WId handle; std::vector keys; - Work(Mappings& m, SelectedLibraries& libs, WId handle); + Work(Mappings& m, QFrame* frame, mem& tracker, mem& filter, mem& proto); ~Work(); void reload_shortcuts(); + bool is_ok() const; private: static std::shared_ptr make_logger(main_settings &s); -- cgit v1.2.3