Bug fix: Add mutex lock
authorYuta Doi <yuta-d@witz-inc.co.jp>
Tue, 12 Jun 2018 09:34:49 +0000 (18:34 +0900)
committerYuta Doi <yuta-d@witz-inc.co.jp>
Tue, 12 Jun 2018 09:34:49 +0000 (18:34 +0900)
Change-Id: Iaa47eb9577167d57f56657660d278ad420306c62
Signed-off-by: Yuta Doi <yuta-d@witz-inc.co.jp>
src/app.cpp
src/app.hpp

index 23d3a2c..0c2423e 100644 (file)
@@ -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<std::mutex> 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<std::mutex> 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<std::mutex> lock(this->mtx);
+
    auto ip = this->controller->sprops.find(id);
    if (ip != this->controller->sprops.end()) {
       char const *label =
index a0615d5..3467666 100644 (file)
@@ -24,6 +24,7 @@
 #include <unordered_map>
 #include <unordered_set>
 #include <experimental/optional>
+#include <mutex>
 #include "config.hpp"
 #include "controller_hooks.hpp"
 #include "layers.hpp"
@@ -263,6 +264,7 @@ private:
    std::unordered_map<std::string, std::string> role2drawingname_;
    std::unordered_map<int, int> appid2role_;
    CarInfo crr_car_info_;
+   std::mutex mtx;
 
    int allocateSurface();
    void setSurfaceSize(const char* role, const char* area);