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 {
|
||||
public:
|
||||
QWaylandBuffer() { }
|
||||
QWaylandBuffer()
|
||||
: mBuffer(0)
|
||||
{
|
||||
}
|
||||
virtual ~QWaylandBuffer() { }
|
||||
wl_buffer *buffer() {return mBuffer;}
|
||||
virtual QSize size() const = 0;
|
||||
|
@ -58,7 +58,8 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
|
||||
const QSize &size, QImage::Format format)
|
||||
: mMarginsImage(0)
|
||||
: mShmPool(0)
|
||||
, mMarginsImage(0)
|
||||
{
|
||||
int stride = size.width() * 4;
|
||||
int alloc = stride * size.height();
|
||||
@ -97,9 +98,12 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display,
|
||||
QWaylandShmBuffer::~QWaylandShmBuffer(void)
|
||||
{
|
||||
delete mMarginsImage;
|
||||
munmap((void *) mImage.constBits(), mImage.byteCount());
|
||||
wl_buffer_destroy(mBuffer);
|
||||
wl_shm_pool_destroy(mShmPool);
|
||||
if (mImage.constBits())
|
||||
munmap((void *) mImage.constBits(), mImage.byteCount());
|
||||
if (mBuffer)
|
||||
wl_buffer_destroy(mBuffer);
|
||||
if (mShmPool)
|
||||
wl_shm_pool_destroy(mShmPool);
|
||||
}
|
||||
|
||||
QImage *QWaylandShmBuffer::imageInsideMargins(const QMargins &margins)
|
||||
|
Loading…
x
Reference in New Issue
Block a user