From ce36f169937d3634ff9a65067c22872ee72aef4c Mon Sep 17 00:00:00 2001 From: Yuta Doi Date: Tue, 12 Jun 2018 18:34:49 +0900 Subject: [PATCH] Bug fix: Add mutex lock Change-Id: Iaa47eb9577167d57f56657660d278ad420306c62 Signed-off-by: Yuta Doi --- src/app.cpp | 9 +++++++++ src/app.hpp | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/app.cpp b/src/app.cpp index 23d3a2c..0c2423e 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -542,6 +542,9 @@ void App::allocateWindowResource(char const *event, char const *drawing_name, } void App::enqueue_flushdraw(int surface_id) { + // lock by mutex + std::lock_guard lock(this->mtx); + this->check_flushdraw(surface_id); HMI_DEBUG("wm", "Enqueuing EndDraw for surface_id %d", surface_id); this->pending_end_draw.push_back(surface_id); @@ -562,6 +565,9 @@ void App::check_flushdraw(int surface_id) { } void App::api_enddraw(char const *appid, char const *drawing_name) { + // lock by mutex + std::lock_guard lock(this->mtx); + // Convert drawing_name to role const char* role = this->convertDrawingNameToRole(drawing_name); @@ -965,6 +971,9 @@ void App::activate(int id) { } void App::deactivate(int id) { + // lock by mutex + std::lock_guard lock(this->mtx); + auto ip = this->controller->sprops.find(id); if (ip != this->controller->sprops.end()) { char const *label = diff --git a/src/app.hpp b/src/app.hpp index a0615d5..3467666 100644 --- a/src/app.hpp +++ b/src/app.hpp @@ -24,6 +24,7 @@ #include #include #include +#include #include "config.hpp" #include "controller_hooks.hpp" #include "layers.hpp" @@ -263,6 +264,7 @@ private: std::unordered_map role2drawingname_; std::unordered_map appid2role_; CarInfo crr_car_info_; + std::mutex mtx; int allocateSurface(); void setSurfaceSize(const char* role, const char* area); -- 2.16.6