Fix shm buffers init and destruction on failure
Some pointers need to be initialized in QWaylandBuffer and QWaylandShmBuffer, and checked at destruction. This avoids crashes when shm surface creation fails. Change-Id: I6f6afa3cc6c67533b5130700cbc27b271764109e Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
This commit is contained in:
parent
babb58933f
commit
43c14e514d
@ -54,7 +54,10 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
class Q_WAYLAND_CLIENT_EXPORT QWaylandBuffer {
|
class Q_WAYLAND_CLIENT_EXPORT QWaylandBuffer {
|
||||||
public:
|
public:
|
||||||
QWaylandBuffer() { }
|
QWaylandBuffer()
|
||||||
|
: mBuffer(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
virtual ~QWaylandBuffer() { }
|
virtual ~QWaylandBuffer() { }
|
||||||
wl_buffer *buffer() {return mBuffer;}
|
wl_buffer *buffer() {return mBuffer;}
|
||||||
virtual QSize size() const = 0;
|
virtual QSize size() const = 0;
|
||||||
|
@ -58,7 +58,8 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
|
QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
|
||||||
const QSize &size, QImage::Format format)
|
const QSize &size, QImage::Format format)
|
||||||
: mMarginsImage(0)
|
: mShmPool(0)
|
||||||
|
, mMarginsImage(0)
|
||||||
{
|
{
|
||||||
int stride = size.width() * 4;
|
int stride = size.width() * 4;
|
||||||
int alloc = stride * size.height();
|
int alloc = stride * size.height();
|
||||||
@ -97,8 +98,11 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
|
|||||||
QWaylandShmBuffer::~QWaylandShmBuffer(void)
|
QWaylandShmBuffer::~QWaylandShmBuffer(void)
|
||||||
{
|
{
|
||||||
delete mMarginsImage;
|
delete mMarginsImage;
|
||||||
|
if (mImage.constBits())
|
||||||
munmap((void *) mImage.constBits(), mImage.byteCount());
|
munmap((void *) mImage.constBits(), mImage.byteCount());
|
||||||
|
if (mBuffer)
|
||||||
wl_buffer_destroy(mBuffer);
|
wl_buffer_destroy(mBuffer);
|
||||||
|
if (mShmPool)
|
||||||
wl_shm_pool_destroy(mShmPool);
|
wl_shm_pool_destroy(mShmPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user