diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2017-12-03 22:23:08 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2017-12-04 12:19:26 +0100 |
commit | b256886a5cb9f2ae3ebda70a2045b19ed9f4233e (patch) | |
tree | 4fa1e46de224cf834a05824dc1eb86001bdb3300 /tracker-fusion/fusion.cpp | |
parent | e89709a801e7874bc02c66848c638c6a0ccc85c1 (diff) |
api: add status check for modules
Diffstat (limited to 'tracker-fusion/fusion.cpp')
-rw-r--r-- | tracker-fusion/fusion.cpp | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/tracker-fusion/fusion.cpp b/tracker-fusion/fusion.cpp index 07f6483f..0b81b682 100644 --- a/tracker-fusion/fusion.cpp +++ b/tracker-fusion/fusion.cpp @@ -22,10 +22,7 @@ static auto get_modules() return Modules(OPENTRACK_BASE_PATH + OPENTRACK_LIBRARY_PATH); } -fusion_tracker::fusion_tracker() : - rot_tracker_data{}, - pos_tracker_data{}, - other_frame(new QFrame) +fusion_tracker::fusion_tracker() { } @@ -52,11 +49,14 @@ const QString& fusion_tracker::caption() return caption; } -void fusion_tracker::start_tracker(QFrame* frame) +module_status fusion_tracker::start_tracker(QFrame* frame) { assert(!rot_tracker && !pos_tracker); assert(!rot_dylib && !pos_dylib); + QString err; + module_status status; + fusion_settings s; const QString rot_tracker_name = s.rot_tracker_name().toString(); const QString pos_tracker_name = s.pos_tracker_name().toString(); @@ -65,14 +65,15 @@ void fusion_tracker::start_tracker(QFrame* frame) assert(pos_tracker_name != own_name); if (rot_tracker_name.isEmpty() || pos_tracker_name.isEmpty()) - goto fail; + { + err = tr("Trackers not selected."); + goto end; + } if (rot_tracker_name == pos_tracker_name) { - QMessageBox::warning(nullptr, caption(), - tr("Select different trackers for rotation and position."), - QMessageBox::Close); - goto cleanup; + err = tr("Select different trackers for rotation and position."); + goto end; } { @@ -95,17 +96,28 @@ void fusion_tracker::start_tracker(QFrame* frame) } if (!rot_dylib || !pos_dylib) - goto fail; + goto end; rot_tracker = make_dylib_instance<ITracker>(rot_dylib); pos_tracker = make_dylib_instance<ITracker>(pos_dylib); - pos_tracker->start_tracker(frame); + status = pos_tracker->start_tracker(frame); + + if (!status.is_ok()) + { + err = pos_dylib->name + QStringLiteral(":\n ") + status.error; + goto end; + } if (frame->layout() == nullptr) { - rot_tracker->start_tracker(frame); + status = rot_tracker->start_tracker(frame); other_frame = nullptr; + if (!status.is_ok()) + { + err = rot_dylib->name + QStringLiteral(":\n ") + status.error; + goto end; + } } else { @@ -121,14 +133,11 @@ void fusion_tracker::start_tracker(QFrame* frame) } - return; - -fail: - QMessageBox::warning(nullptr, - caption(), tr("Select rotation and position trackers."), - QMessageBox::Close); -cleanup: - other_frame = nullptr; +end: + if (!err.isEmpty()) + return error(err); + else + return status_ok(); } void fusion_tracker::data(double *data) @@ -203,4 +212,4 @@ fusion_settings::fusion_settings() : { } -OPENTRACK_DECLARE_TRACKER(fusion_tracker, fusion_dialog, fusion_metadata)
\ No newline at end of file +OPENTRACK_DECLARE_TRACKER(fusion_tracker, fusion_dialog, fusion_metadata) |