Skip to content

Commit bcde6fb

Browse files
committed
Fix get null handle in a valid qwobject
Fix null pointer access issue encountered in EventItem::contains, When WXWaylandSurface calls safeDeleteLater to destroy, WSurface should invalidated in time
1 parent 327cfe6 commit bcde6fb

4 files changed

Lines changed: 12 additions & 5 deletions

File tree

qwlroots

src/server/kernel/wglobal.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ QW_NAMESPACE::qw_object_basic *WWrapObject::handle() const
202202
bool WWrapObject::isInvalidated() const
203203
{
204204
W_DC(WWrapObject);
205+
206+
Q_ASSERT_X(d->invalidated || handle() != nullptr, Q_FUNC_INFO, "WWrapObject not invalidate in time");
207+
205208
return d->invalidated;
206209
}
207210

src/server/protocols/wxwaylandsurface.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,11 @@ class Q_DECL_HIDDEN WXWaylandSurfacePrivate : public WToplevelSurfacePrivate
6464
void WXWaylandSurfacePrivate::instantRelease()
6565
{
6666
handle()->set_data(nullptr, nullptr);
67-
if (surface)
68-
surface->removeAttachedData<WXWaylandSurface>();
67+
68+
if (!surface)
69+
return;
70+
surface->safeDeleteLater();
71+
surface = nullptr;
6972
}
7073

7174
void WXWaylandSurfacePrivate::init()

src/server/qtquick/private/wsurfaceitem_p.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include "wsurfaceitem.h"
77
#include "wsurface.h"
8+
#include "wwrappointer.h"
89

910
#include <QQuickWindow>
1011
#include <QSGImageNode>
@@ -63,8 +64,8 @@ class Q_DECL_HIDDEN WSurfaceItemPrivate : public QQuickItemPrivate
6364
}
6465

6566
Q_DECLARE_PUBLIC(WSurfaceItem)
66-
QPointer<WSurface> surface;
67-
QPointer<WToplevelSurface> shellSurface;
67+
WWrapPointer<WSurface> surface;
68+
WWrapPointer<WToplevelSurface> shellSurface;
6869
std::unique_ptr<SurfaceState> surfaceState;
6970
QQuickItem *contentContainer = nullptr;
7071
QQmlComponent *delegate = nullptr;

0 commit comments

Comments
 (0)