Skip to content

Commit e82679a

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 e82679a

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

src/server/kernel/wglobal.cpp

+3
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

+7-2
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,14 @@ class Q_DECL_HIDDEN WXWaylandSurfacePrivate : public WToplevelSurfacePrivate
6363

6464
void WXWaylandSurfacePrivate::instantRelease()
6565
{
66+
W_Q(WXWaylandSurface);
6667
handle()->set_data(nullptr, nullptr);
67-
if (surface)
68-
surface->removeAttachedData<WXWaylandSurface>();
68+
handle()->disconnect(q);
69+
70+
if (!surface)
71+
return;
72+
surface->safeDeleteLater();
73+
surface = nullptr;
6974
}
7075

7176
void WXWaylandSurfacePrivate::init()

src/server/qtquick/private/wsurfaceitem_p.h

+3-2
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)