Skip to content

Commit

Permalink
Disambiguate multiple QWaylandBuffer pointers
Browse files Browse the repository at this point in the history
We carry multiple pointers to the same QWaylandBuffer object and when it
gets destroyed in a subclass, we still try to access the same object
from the superclass. Fixing this by removing the pointer from the
subclasses.
Also, to my understanding, we should signal the destruction to wayland by
a wl_destroy_buffer call from the client.

Change-Id: I67623e24452e92e9a4a0498b9b0b73d5b1b06c3a
  • Loading branch information
Florian Haenel committed Dec 3, 2012
1 parent c2651cb commit 95ffeba
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
Expand Up @@ -57,7 +57,6 @@ QWaylandXCompositeEGLWindow::QWaylandXCompositeEGLWindow(QWindow *window, QWayla
: QWaylandWindow(window)
, m_glxIntegration(glxIntegration)
, m_context(0)
, m_buffer(0)
, m_xWindow(0)
, m_config(q_configFromGLFormat(glxIntegration->eglDisplay(), window->format(), true, EGL_WINDOW_BIT | EGL_PIXMAP_BIT))
, m_surface(0)
Expand Down Expand Up @@ -96,7 +95,8 @@ void QWaylandXCompositeEGLWindow::createEglSurface()
size = QSize(1,1);
}

delete m_buffer;
delete mBuffer;
mBuffer = 0;
//XFreePixmap deletes the glxPixmap as well
if (m_xWindow) {
XDestroyWindow(m_glxIntegration->xDisplay(), m_xWindow);
Expand Down Expand Up @@ -128,10 +128,10 @@ void QWaylandXCompositeEGLWindow::createEglSurface()
}

XSync(m_glxIntegration->xDisplay(),False);
m_buffer = new QWaylandXCompositeBuffer(m_glxIntegration->waylandXComposite(),
mBuffer = new QWaylandXCompositeBuffer(m_glxIntegration->waylandXComposite(),
(uint32_t)m_xWindow,
size);
attach(m_buffer);
attach(mBuffer);

m_waitingForSync = true;
struct wl_callback *callback = wl_display_sync(m_glxIntegration->waylandDisplay()->wl_display());
Expand Down
Expand Up @@ -64,7 +64,6 @@ class QWaylandXCompositeEGLWindow : public QWaylandWindow

QWaylandXCompositeEGLIntegration *m_glxIntegration;
QWaylandXCompositeEGLContext *m_context;
QWaylandBuffer *m_buffer;

Window m_xWindow;
EGLConfig m_config;
Expand Down
Expand Up @@ -54,7 +54,6 @@ QWaylandXCompositeGLXWindow::QWaylandXCompositeGLXWindow(QWindow *window, QWayla
, m_glxIntegration(glxIntegration)
, m_xWindow(0)
, m_config(qglx_findConfig(glxIntegration->xDisplay(), glxIntegration->screen(), window->format(), GLX_WINDOW_BIT | GLX_PIXMAP_BIT))
, m_buffer(0)
, m_syncCallback(0)
{
}
Expand All @@ -70,8 +69,8 @@ void QWaylandXCompositeGLXWindow::setGeometry(const QRect &rect)
QWaylandWindow::setGeometry(rect);

if (m_xWindow) {
delete m_buffer;

delete mBuffer;
mBuffer = 0;
XDestroyWindow(m_glxIntegration->xDisplay(), m_xWindow);
m_xWindow = 0;
}
Expand Down Expand Up @@ -130,10 +129,10 @@ void QWaylandXCompositeGLXWindow::createSurface()
XMapWindow(m_glxIntegration->xDisplay(), m_xWindow);

XSync(m_glxIntegration->xDisplay(), False);
m_buffer = new QWaylandXCompositeBuffer(m_glxIntegration->waylandXComposite(),
mBuffer = new QWaylandXCompositeBuffer(m_glxIntegration->waylandXComposite(),
(uint32_t)m_xWindow,
size);
attach(m_buffer);
attach(mBuffer);
waitForSync();
}

Expand Down
Expand Up @@ -68,8 +68,6 @@ class QWaylandXCompositeGLXWindow : public QWaylandWindow
Window m_xWindow;
GLXFBConfig m_config;

QWaylandBuffer *m_buffer;

void waitForSync();
wl_callback *m_syncCallback;

Expand Down
Expand Up @@ -57,3 +57,8 @@ QSize QWaylandXCompositeBuffer::size() const
{
return mSize;
}

QWaylandXCompositeBuffer::~QWaylandXCompositeBuffer()
{
wl_buffer_destroy(mBuffer);
}
Expand Up @@ -54,7 +54,7 @@ class QWaylandXCompositeBuffer : public QWaylandBuffer
QWaylandXCompositeBuffer(struct wl_xcomposite *xcomposite,
uint32_t window,
const QSize &size);

~QWaylandXCompositeBuffer();
QSize size() const;
private:
QSize mSize;
Expand Down

0 comments on commit 95ffeba

Please sign in to comment.