diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp
index a4f4e1fddb05036268d3d5e820552e47a0f642cc..205cea7a3aa86b29f8dbcea75fe212618038d6ac 100644
--- a/src/compositor/compositor_api/qwaylandsurface.cpp
+++ b/src/compositor/compositor_api/qwaylandsurface.cpp
@@ -330,14 +330,7 @@ void QWaylandSurface::destroySurface()
 {
     QWaylandSurfaceOp op(QWaylandSurfaceOp::Close);
     if (!sendInterfaceOp(op))
-        destroySurfaceByForce();
-}
-
-void QWaylandSurface::destroySurfaceByForce()
-{
-    Q_D(QWaylandSurface);
-   wl_resource *surface_resource = d->resource()->handle;
-   wl_resource_destroy(surface_resource);
+        emit surfaceDestroyed();
 }
 
 /*!
diff --git a/src/compositor/compositor_api/qwaylandsurface.h b/src/compositor/compositor_api/qwaylandsurface.h
index 77e871365cc5343438233a07435528412e35503d..7c7ec4d764d03c1060d37b064090ea568b5811da 100644
--- a/src/compositor/compositor_api/qwaylandsurface.h
+++ b/src/compositor/compositor_api/qwaylandsurface.h
@@ -170,7 +170,6 @@ public:
 
     Q_INVOKABLE void destroy();
     Q_INVOKABLE void destroySurface();
-    Q_INVOKABLE void destroySurfaceByForce();
     Q_INVOKABLE void ping();
 
     void ref();
diff --git a/src/compositor/wayland_wrapper/qwlextendedsurface.cpp b/src/compositor/wayland_wrapper/qwlextendedsurface.cpp
index ee68ed19633e0f15be39fdfa8dbcad1e2827cddb..55878295ddce43c643be659329f4523a879d58f0 100644
--- a/src/compositor/wayland_wrapper/qwlextendedsurface.cpp
+++ b/src/compositor/wayland_wrapper/qwlextendedsurface.cpp
@@ -72,7 +72,8 @@ ExtendedSurface::ExtendedSurface(struct wl_client *client, uint32_t id, int vers
 
 ExtendedSurface::~ExtendedSurface()
 {
-    m_surface->setExtendedSurface(0);
+    if (m_surface)
+        m_surface->setExtendedSurface(0);
 }
 
 void ExtendedSurface::sendGenericProperty(const QString &name, const QVariant &variant)
@@ -91,6 +92,11 @@ void ExtendedSurface::setVisibility(QWindow::Visibility visibility, bool updateC
         send_onscreen_visibility(visibility);
 }
 
+void ExtendedSurface::setParentSurface(Surface *surface)
+{
+    m_surface = surface;
+}
+
 bool ExtendedSurface::runOperation(QWaylandSurfaceOp *op)
 {
     switch (op->type()) {
@@ -141,7 +147,7 @@ void ExtendedSurface::extended_surface_set_content_orientation_mask(Resource *re
     Qt::ScreenOrientations oldMask = m_contentOrientationMask;
     m_contentOrientationMask = mask;
 
-    if (mask != oldMask)
+    if (m_surface && mask != oldMask)
         emit m_surface->waylandSurface()->orientationUpdateMaskChanged();
 }
 
@@ -168,7 +174,7 @@ void ExtendedSurface::extended_surface_set_window_flags(Resource *resource, int3
 {
     Q_UNUSED(resource);
     QWaylandSurface::WindowFlags windowFlags(flags);
-    if (windowFlags== m_windowFlags)
+    if (m_surface || windowFlags == m_windowFlags)
         return;
     m_windowFlags = windowFlags;
     emit m_surface->waylandSurface()->windowFlagsChanged(windowFlags);
@@ -181,12 +187,14 @@ void ExtendedSurface::extended_surface_destroy_resource(Resource *)
 
 void ExtendedSurface::extended_surface_raise(Resource *)
 {
-    emit m_surface->waylandSurface()->raiseRequested();
+    if (m_surface)
+        emit m_surface->waylandSurface()->raiseRequested();
 }
 
 void ExtendedSurface::extended_surface_lower(Resource *)
 {
-    emit m_surface->waylandSurface()->lowerRequested();
+    if (m_surface)
+        emit m_surface->waylandSurface()->lowerRequested();
 }
 
 }
diff --git a/src/compositor/wayland_wrapper/qwlextendedsurface_p.h b/src/compositor/wayland_wrapper/qwlextendedsurface_p.h
index c644566669a8981a4a4e3dd21cee049039238dc7..9bcb28272f50d5133cc07fc17a13198966acc7de 100644
--- a/src/compositor/wayland_wrapper/qwlextendedsurface_p.h
+++ b/src/compositor/wayland_wrapper/qwlextendedsurface_p.h
@@ -87,6 +87,7 @@ public:
     ExtendedSurface *parent() const;
     void setParent(ExtendedSurface *parent);
     QLinkedList<QWaylandSurface *> subSurfaces() const;
+    void setParentSurface(Surface *s);
 
     Qt::ScreenOrientations contentOrientationMask() const;
 
diff --git a/src/compositor/wayland_wrapper/qwlshellsurface.cpp b/src/compositor/wayland_wrapper/qwlshellsurface.cpp
index 97380feba394b9420ccfc8bd345b7dbd4fbb2cfd..80304f3cbabb17fdf4ef831dea0c0654690c4ce9 100644
--- a/src/compositor/wayland_wrapper/qwlshellsurface.cpp
+++ b/src/compositor/wayland_wrapper/qwlshellsurface.cpp
@@ -91,7 +91,6 @@ ShellSurface::ShellSurface(Shell *shell, wl_client *client, uint32_t id, Surface
     , wl_shell_surface(client, id, 1)
     , m_shell(shell)
     , m_surface(surface)
-    , m_deleting(false)
     , m_resizeGrabber(0)
     , m_moveGrabber(0)
     , m_popupGrabber(0)
@@ -104,13 +103,6 @@ ShellSurface::ShellSurface(Shell *shell, wl_client *client, uint32_t id, Surface
 
 ShellSurface::~ShellSurface()
 {
-    // We must destroy the wl_resource here, but be careful not to do it
-    // if we're here from shell_surface_destroy_resource(), i.e. if the
-    // wl_resource was destroyed already
-    if (!m_deleting) {
-        m_deleting = true;
-        wl_resource_destroy(resource()->handle);
-    }
 }
 
 void ShellSurface::sendConfigure(uint32_t edges, int32_t width, int32_t height)
@@ -200,11 +192,7 @@ void ShellSurface::shell_surface_destroy_resource(Resource *)
     if (m_popupGrabber)
         m_popupGrabber->removePopup(this);
 
-    // If we're here from the destructor don't delete this again
-    if (!m_deleting) {
-        m_deleting = true;
-        delete this;
-    }
+    delete this;
 }
 
 void ShellSurface::shell_surface_move(Resource *resource,
diff --git a/src/compositor/wayland_wrapper/qwlshellsurface_p.h b/src/compositor/wayland_wrapper/qwlshellsurface_p.h
index f724ef290022c18560c4dba2d6c0cde4584eb896..92405bbc9d0d0faa8b72424b161fed8e3318e1bc 100644
--- a/src/compositor/wayland_wrapper/qwlshellsurface_p.h
+++ b/src/compositor/wayland_wrapper/qwlshellsurface_p.h
@@ -112,7 +112,6 @@ private:
     Shell *m_shell;
     Surface *m_surface;
     QWaylandSurfaceView *m_view;
-    bool m_deleting;
 
     ShellSurfaceResizeGrabber *m_resizeGrabber;
     ShellSurfaceMoveGrabber *m_moveGrabber;
diff --git a/src/compositor/wayland_wrapper/qwlsurface.cpp b/src/compositor/wayland_wrapper/qwlsurface.cpp
index e63fcff256872518c73f1675250d43fdc9b909a7..5cd8bb50668815c5bdec8d8fe8adc53efdae9665 100644
--- a/src/compositor/wayland_wrapper/qwlsurface.cpp
+++ b/src/compositor/wayland_wrapper/qwlsurface.cpp
@@ -338,8 +338,7 @@ Qt::ScreenOrientation Surface::contentOrientation() const
 void Surface::surface_destroy_resource(Resource *)
 {
     if (m_extendedSurface) {
-        if (m_extendedSurface->resource())
-            wl_resource_destroy(m_extendedSurface->resource()->handle);
+        m_extendedSurface->setParentSurface(Q_NULLPTR);
         m_extendedSurface = 0;
     }