diff options
author | Kazumasa Mitsunari <knimitz@witz-inc.co.jp> | 2018-03-19 17:06:05 +0900 |
---|---|---|
committer | Kazumasa Mitsunari <knimitz@witz-inc.co.jp> | 2018-03-19 19:37:37 +0900 |
commit | c83642c69ede418f4c4d89daa0dae4b8698e0765 (patch) | |
tree | ae79ff05e6e4e49cfc5037090c214fdcab8dcd1e /src/main.cpp | |
parent | 5d05965a888976ee4b8cf65e25c01bbff8769b3c (diff) |
Change reply timing
Some events were emitted in a function before it replies.
This patch changes
* The function checks parameter then reply error if it is incorrect.
* After checking parameters, the function continues to process.
The exeption is the syncronous functions such as requestSurface.
Change-Id: I168eba3e2b70d53615a4221bcbbba6bc6096c1db
Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/src/main.cpp b/src/main.cpp index fd96d33..2f813a3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -298,15 +298,18 @@ void windowmanager_activatesurface(afb_req req) noexcept { return; } - auto ret = g_afb_instance->app.api_activate_surface(a_drawing_name, a_drawing_area); - if (ret != nullptr) { - afb_req_fail(req, "failed", ret); - return; - } + g_afb_instance->app.api_activate_surface(a_drawing_name, a_drawing_area, + [&req](const char* errmsg){ + if (errmsg != nullptr) { + HMI_ERROR("wm", errmsg); + afb_req_fail(req, "failed", errmsg); + return; + } + afb_req_success(req, NULL, "success"); + }); - afb_req_success(req, NULL, "success"); } catch (std::exception &e) { - afb_req_fail_f(req, "failed", "Uncaught exception while calling activatesurface: %s", e.what()); + HMI_WARNING("wm", "failed", "Uncaught exception while calling activatesurface: %s", e.what()); return; } @@ -329,15 +332,18 @@ void windowmanager_deactivatesurface(afb_req req) noexcept { return; } - auto ret = g_afb_instance->app.api_deactivate_surface(a_drawing_name); - if (ret != nullptr) { - afb_req_fail(req, "failed", ret); - return; - } + g_afb_instance->app.api_deactivate_surface(a_drawing_name, + [&req](const char* errmsg){ + if (errmsg != nullptr) { + HMI_ERROR("wm", errmsg); + afb_req_fail(req, "failed", errmsg); + return; + } + afb_req_success(req, NULL, "success"); + }); - afb_req_success(req, NULL, "success"); } catch (std::exception &e) { - afb_req_fail_f(req, "failed", "Uncaught exception while calling deactivatesurface: %s", e.what()); + HMI_WARNING("wm", "Uncaught exception while calling deactivatesurface: %s", e.what()); return; } } @@ -358,16 +364,12 @@ void windowmanager_enddraw(afb_req req) noexcept { afb_req_fail(req, "failed", "Need char const* argument drawing_name"); return; } + afb_req_success(req, NULL, "success"); - auto ret = g_afb_instance->app.api_enddraw(a_drawing_name); - if (ret != nullptr) { - afb_req_fail(req, "failed", ret); - return; - } + g_afb_instance->app.api_enddraw(a_drawing_name); - afb_req_success(req, NULL, "success"); } catch (std::exception &e) { - afb_req_fail_f(req, "failed", "Uncaught exception while calling enddraw: %s", e.what()); + HMI_WARNING("wm", "failed", "Uncaught exception while calling enddraw: %s", e.what()); return; } |