diff options
author | 2018-06-12 18:16:26 +0900 | |
---|---|---|
committer | 2018-06-12 18:16:26 +0900 | |
commit | 1024e4747621cb4b45384afef671df6d15a9e2c0 (patch) | |
tree | 0be1956cf01e7092a936d8f37512d7acdddcb867 /src/applist.cpp | |
parent | 924df5ddaf2f79cb4e7597661acc3840f9844a59 (diff) |
Bug Fix : vector contents vanishes
When Window Manager handles applist as pointer(smart pointer),
the contents of vector vanishes when callback function accesses it.
I don't know how to fix, then move applist out to global variable in app.cpp
In this way, vecotr contents doesn't vanish
Change-Id: Ic1cbb12279c82b6debbd608dbb7fb37089f92538
Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
Diffstat (limited to 'src/applist.cpp')
-rw-r--r-- | src/applist.cpp | 53 |
1 files changed, 34 insertions, 19 deletions
diff --git a/src/applist.cpp b/src/applist.cpp index 06c1d86..7249130 100644 --- a/src/applist.cpp +++ b/src/applist.cpp @@ -62,9 +62,13 @@ bool AppList::contains(const string &appid) const void AppList::removeSurface(unsigned surface_id){ // This function may be very slow + this->clientDump(); + for (int i = 0; i < 1000; i++) + ; bool ret = false; for (auto &x : this->app2client) { + HMI_DEBUG("wm", "app: %s", x.second->appID()); ret = x.second->removeSurfaceIfExist(surface_id); if(ret){ HMI_DEBUG("wm", "remove surface %d from Client %s finish", surface_id, x.second->appID().c_str()); @@ -98,16 +102,18 @@ WMError AppList::popFloatingSurface(unsigned pid, unsigned *surface) { WMError ret = WMError::NO_ENTRY; - for (auto itr = this->floating_surfaces.begin(); itr != this->floating_surfaces.end(); ++itr) - { - if(pid == itr->pid){ - *surface = itr->surface_id; - itr = this->floating_surfaces.erase(itr); - ret = WMError::SUCCESS; - HMI_DEBUG("wm", "Erase surface %d", *surface); - break; - } - } + auto rmv_begin = std::remove_if(this->floating_surfaces.begin(), this->floating_surfaces.end(), + [pid, surface, &ret](FloatingSurface x) { + if(pid == x.pid){ + *surface = x.surface_id; + ret = WMError::SUCCESS; + return true; + } + else{ + return false; + } + }); + this->floating_surfaces.erase(rmv_begin, this->floating_surfaces.end()); return ret; } @@ -125,19 +131,17 @@ void AppList::addFloatingSurface(unsigned surface, unsigned pid) { struct FloatingSurface fsurface{surface, pid}; this->floating_surfaces.push_back(fsurface); + this->dumpFloatingSurfaces(); } void AppList::removeFloatingSurface(unsigned surface) { - for (auto itr = this->floating_surfaces.begin(); itr != this->floating_surfaces.end(); ++itr) - { - if (surface == itr->surface_id) - { - HMI_DEBUG("wm", "Erase surface %d", itr->surface_id); - itr = this->floating_surfaces.erase(itr); - break; - } - } + this->dumpFloatingSurfaces(); + auto rmv_begin = std::remove_if(this->floating_surfaces.begin(), this->floating_surfaces.end(), + [surface](FloatingSurface x) { + return x.surface_id == surface; + }); + this->floating_surfaces.erase(rmv_begin, this->floating_surfaces.end()); } WMError AppList::appendRole(const std::string &id, const std::string &role, unsigned surface) @@ -368,4 +372,15 @@ void AppList::reqDump() } DUMP("======= req dump end =====\n"); } + +void AppList::dumpFloatingSurfaces() +{ + DUMP("======= floating surface dump ====="); + for (const auto &x : this->floating_surfaces) + { + DUMP("surface : %d, pid : %d", x.surface_id, x.pid); + } + DUMP("======= floating surface dump end =====\n"); +} + } // namespace wm
\ No newline at end of file |