wayland: only create layers and surfaces when necessary
authorMarcus Fritzsch <marcus_fritzsch@mentor.com>
Wed, 30 Aug 2017 12:46:01 +0000 (14:46 +0200)
committerMarcus Fritzsch <marcus_fritzsch@mentor.com>
Mon, 4 Sep 2017 14:54:00 +0000 (16:54 +0200)
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
src/wayland.cpp

index 01ac275..df601eb 100644 (file)
@@ -234,15 +234,21 @@ void controller::controller_screen(uint32_t id,
 
 void controller::controller_layer(uint32_t id) {
    logdebug("genivi::controller @ %p layer %u (%x)", this->proxy.get(), id, id);
-   auto &l = this->layers[id] = std::make_unique<struct layer>(id, this);
-   l->clear_surfaces();
+   if (this->layers.find(id) != this->layers.end()) {
+      logerror("Someone created a layer without asking US! (%d)", id);
+   } else {
+      auto &l = this->layers[id] = std::make_unique<struct layer>(id, this);
+      l->clear_surfaces();
+   }
 }
 
 void controller::controller_surface(uint32_t id) {
    logdebug("genivi::controller @ %p surface %u (%x)", this->proxy.get(), id,
             id);
-   this->surfaces[id] = std::make_unique<struct surface>(id, this);
-   this->chooks->surface_created(id);
+   if (this->surfaces.find(id) == this->surfaces.end()) {
+      this->surfaces[id] = std::make_unique<struct surface>(id, this);
+      this->chooks->surface_created(id);
+   }
 }
 
 void controller::controller_error(int32_t object_id, int32_t object_type,