From 817c7e0c365e9b0e2b9d4f3ed06dd192a57bd6af Mon Sep 17 00:00:00 2001
From: Giulio Camuffo <giulio.camuffo@jollamobile.com>
Date: Thu, 23 Apr 2015 19:32:28 +0300
Subject: [PATCH] Fix crash when the wl_shm global comes after a wl_output one
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Task-number: QTBUG-44503
Change-Id: I6932df57bb4560b6dceb72a5cb7c536cd090e92a
Reviewed-by: Martin Gräßlin <mgraesslin@kde.org>
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
---
 src/client/qwaylanddisplay.cpp | 1 +
 src/client/qwaylandscreen.cpp  | 7 ++++++-
 src/client/qwaylandscreen_p.h  | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp
index e0155fc95..c3925f5c4 100644
--- a/src/client/qwaylanddisplay.cpp
+++ b/src/client/qwaylanddisplay.cpp
@@ -239,6 +239,7 @@ void QWaylandDisplay::registry_global(uint32_t id, const QString &interface, uin
         mScreens.append(screen);
         // We need to get the output events before creating surfaces
         forceRoundTrip();
+        screen->init();
         mWaylandIntegration->screenAdded(screen);
     } else if (interface == QStringLiteral("wl_compositor")) {
         mCompositorVersion = qMin((int)version, 3);
diff --git a/src/client/qwaylandscreen.cpp b/src/client/qwaylandscreen.cpp
index acd125c62..8a01e366e 100644
--- a/src/client/qwaylandscreen.cpp
+++ b/src/client/qwaylandscreen.cpp
@@ -60,7 +60,7 @@ QWaylandScreen::QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uin
     , mFormat(QImage::Format_ARGB32_Premultiplied)
     , mOutputName(QStringLiteral("Screen%1").arg(id))
     , m_orientation(Qt::PrimaryOrientation)
-    , mWaylandCursor(new QWaylandCursor(this))
+    , mWaylandCursor(0)
 {
     // handle case of output extension global being sent after outputs
     createExtendedOutput();
@@ -71,6 +71,11 @@ QWaylandScreen::~QWaylandScreen()
     delete mWaylandCursor;
 }
 
+void QWaylandScreen::init()
+{
+    mWaylandCursor = new QWaylandCursor(this);
+}
+
 QWaylandDisplay * QWaylandScreen::display() const
 {
     return mWaylandDisplay;
diff --git a/src/client/qwaylandscreen_p.h b/src/client/qwaylandscreen_p.h
index 35adee34a..06389f7e4 100644
--- a/src/client/qwaylandscreen_p.h
+++ b/src/client/qwaylandscreen_p.h
@@ -53,6 +53,7 @@ public:
     QWaylandScreen(QWaylandDisplay *waylandDisplay, int version, uint32_t id);
     ~QWaylandScreen();
 
+    void init();
     QWaylandDisplay *display() const;
 
     QRect geometry() const;
-- 
GitLab