From e8a9ad4aa03e55d9b218822fe575fdc6ae97bac8 Mon Sep 17 00:00:00 2001 From: Marcus Fritzsch Date: Wed, 30 Aug 2017 14:46:01 +0200 Subject: [PATCH] wayland: only create layers and surfaces when necessary Signed-off-by: Marcus Fritzsch --- src/wayland.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/wayland.cpp b/src/wayland.cpp index 01ac275..df601eb 100644 --- a/src/wayland.cpp +++ b/src/wayland.cpp @@ -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(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(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(id, this); - this->chooks->surface_created(id); + if (this->surfaces.find(id) == this->surfaces.end()) { + this->surfaces[id] = std::make_unique(id, this); + this->chooks->surface_created(id); + } } void controller::controller_error(int32_t object_id, int32_t object_type, -- 2.16.6