App: be more thorough on (de)activate()
authorMarcus Fritzsch <marcus_fritzsch@mentor.com>
Tue, 12 Sep 2017 09:29:39 +0000 (11:29 +0200)
committerMarcus Fritzsch <marcus_fritzsch@mentor.com>
Tue, 12 Sep 2017 09:29:39 +0000 (11:29 +0200)
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
src/app.cpp

index 3085c61..4feeb03 100644 (file)
@@ -678,7 +678,8 @@ result<int> App::api_request_surface(char const *drawing_name) {
 }
 
 void App::activate(int id) {
-   if (this->controller->sprops[id].visibility == 0) {
+   auto ip = this->controller->sprops.find(id);
+   if (ip != this->controller->sprops.end() && ip->second.visibility == 0) {
       this->controller->surfaces[id]->set_visibility(1);
       char const *label =
          this->lookup_name(id).value_or("unknown-name").c_str();
@@ -688,7 +689,8 @@ void App::activate(int id) {
 }
 
 void App::deactivate(int id) {
-   if (this->controller->sprops[id].visibility != 0) {
+   auto ip = this->controller->sprops.find(id);
+   if (ip != this->controller->sprops.end() && ip->second.visibility != 0) {
       this->controller->surfaces[id]->set_visibility(0);
       char const *label =
          this->lookup_name(id).value_or("unknown-name").c_str();