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 /logic/runtime-libraries.cpp | |
parent | e89709a801e7874bc02c66848c638c6a0ccc85c1 (diff) |
api: add status check for modules
Diffstat (limited to 'logic/runtime-libraries.cpp')
-rw-r--r-- | logic/runtime-libraries.cpp | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/logic/runtime-libraries.cpp b/logic/runtime-libraries.cpp index a04da6a2..8feeaaba 100644 --- a/logic/runtime-libraries.cpp +++ b/logic/runtime-libraries.cpp @@ -1,13 +1,13 @@ #include "runtime-libraries.hpp" #include "options/scoped.hpp" +#include <QMessageBox> #include <QDebug> -runtime_libraries::runtime_libraries(QFrame* frame, dylibptr t, dylibptr p, dylibptr f) : - pTracker(nullptr), - pFilter(nullptr), - pProtocol(nullptr), - correct(false) +runtime_libraries::runtime_libraries(QFrame* frame, dylibptr t, dylibptr p, dylibptr f) { + module_status status = + module_status_mixin::error(QCoreApplication::translate("module", "Library load failure")); + using namespace options; with_tracker_teardown sentinel; @@ -15,15 +15,12 @@ runtime_libraries::runtime_libraries(QFrame* frame, dylibptr t, dylibptr p, dyli pProtocol = make_dylib_instance<IProtocol>(p); if (!pProtocol) - { - qDebug() << "protocol dylib load failure"; goto end; - } - if(!pProtocol->correct()) + if(status = pProtocol->check_status(), !status.is_ok()) { - qDebug() << "protocol load failure"; - pProtocol = nullptr; + status = QCoreApplication::translate("module", "Error occured while loading protocol %1\n\n%2\n") + .arg(p->name).arg(status.error); goto end; } @@ -36,10 +33,30 @@ runtime_libraries::runtime_libraries(QFrame* frame, dylibptr t, dylibptr p, dyli goto end; } - pTracker->start_tracker(frame); + if (pFilter) + if(status = pFilter->check_status(), !status.is_ok()) + { + status = QCoreApplication::translate("module", "Error occured while loading filter %1\n\n%2\n") + .arg(f->name).arg(status.error); + goto end; + } + + if (status = pTracker->start_tracker(frame), !status.is_ok()) + { + status = QCoreApplication::translate("module", "Error occured while loading tracker %1\n\n%2\n") + .arg(t->name).arg(status.error); + goto end; + } correct = true; + return; + end: - (void)0; + pTracker = nullptr; + pFilter = nullptr; + pProtocol = nullptr; + + if (!status.is_ok()) + QMessageBox::critical(nullptr, "Startup failure", status.error, QMessageBox::Cancel, QMessageBox::NoButton); } |