aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuta Doi <yuta-d@witz-inc.co.jp>2018-06-05 13:23:02 +0900
committerYuta Doi <yuta-d@witz-inc.co.jp>2018-06-05 13:36:53 +0900
commitd1a2de659ca820cbe2748a318fc48e245750cacf (patch)
treec88ac05c3765e1d5043dfb5e0dbdde9d24ace43b
parentdaebef23d579cd9826731bc6c7fcfba74e24531d (diff)
Bug fix: refer the released memory of role name
Change-Id: I67aa440a37f8955da2d7daaf1f6ace95016b763d Signed-off-by: Yuta Doi <yuta-d@witz-inc.co.jp>
-rw-r--r--src/app.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/app.cpp b/src/app.cpp
index be4782a..1e7a617 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -95,7 +95,7 @@ struct result<layer_map> load_layer_map(char const *filename) {
namespace rm {
App *context;
-const char *g_new_role; // TODO: workaround
+std::string g_new_role; // TODO: workaround
static void eventHandler(json_object* json_out) {
context->updateWindowResource(json_out);
}
@@ -103,7 +103,7 @@ static void eventHandler(json_object* json_out) {
void App::updateWindowResource(json_object* json_out) {
- HMI_DEBUG("wm", "role:%s", rm::g_new_role);
+ HMI_DEBUG("wm", "role:%s", rm::g_new_role.c_str());
// Check parking brake state
json_object* json_parking_brake;
@@ -246,14 +246,12 @@ void App::updateWindowResource(json_object* json_out) {
// Get category
const char* category = nullptr;
std::string str_category;
- if (nullptr != rm::g_new_role) {
- str_category = this->pm_.roleToCategory(rm::g_new_role);
- category = str_category.c_str();
- HMI_DEBUG("wm", "role:%s category:%s", rm::g_new_role, category);
- }
+ str_category = this->pm_.roleToCategory(rm::g_new_role.c_str());
+ category = str_category.c_str();
+ HMI_DEBUG("wm", "role:%s category:%s", rm::g_new_role.c_str(), category);
// Update layout
- if (this->lm_.updateLayout(json_out, rm::g_new_role, category)) {
+ if (this->lm_.updateLayout(json_out, rm::g_new_role.c_str(), category)) {
HMI_DEBUG("wm", "Layer is changed!!");
// Allocate surface
@@ -525,7 +523,7 @@ void App::allocateWindowResource(char const *event, char const *drawing_name,
if (nullptr != new_area) {
json_object_object_add(json_in, "area", json_object_new_string(new_area));
}
- rm::g_new_role = new_role; // TODO: workaround
+ rm::g_new_role = std::string(new_role); // TODO: workaround
this->pm_.inputEvent(json_in);
// Release json_object