Avoid seg fault when no output exists
[apps/agl-service-windowmanager.git] / src / window_manager.cpp
index e9cc53a..28692ca 100644 (file)
@@ -194,13 +194,19 @@ int WindowManager::init()
             this->controller->chooks = &this->chooks;
 
             // This protocol needs the output, so lets just add our mapping here...
-            this->controller->add_proxy_to_id_mapping(
-                this->outputs.front()->proxy.get(),
-                wl_proxy_get_id(reinterpret_cast<struct wl_proxy *>(
-                    this->outputs.front()->proxy.get())));
-
-            // Create screen
-            this->controller->create_screen(this->outputs.front()->proxy.get());
+            if(!this->outputs.empty()) {
+                // FIXME : Work around to avoid signal 11. Window Manager can't handle hotplug.
+                this->controller->add_proxy_to_id_mapping(
+                    this->outputs.front()->proxy.get(),
+                    wl_proxy_get_id(reinterpret_cast<struct wl_proxy *>(
+                        this->outputs.front()->proxy.get())));
+
+                // Create screen
+                this->controller->create_screen(this->outputs.front()->proxy.get());
+            }
+            else {
+                HMI_WARNING("wm", "No output object. Window Manager can't handle screen");
+            }
 
             // Set display to controller
             this->controller->display = this->display;