[wayland] Reference BufferInterface in WindowPixmap

As long as our WindowPixmap uses the buffer we should have it referenced.
icc-effect-5.14.5
Martin Gräßlin 2015-03-04 07:54:40 +01:00
parent 209b62d522
commit cfba4bacdf
1 changed files with 7 additions and 0 deletions

View File

@ -993,8 +993,15 @@ bool WindowPixmap::isValid() const
void WindowPixmap::updateBuffer()
{
if (auto s = toplevel()->surface()) {
using namespace KWayland::Server;
if (auto b = s->buffer()) {
if (m_buffer) {
QObject::disconnect(m_buffer.data(), &BufferInterface::aboutToBeDestroyed, m_buffer.data(), &BufferInterface::unref);
m_buffer->unref();
}
m_buffer = b;
m_buffer->ref();
QObject::connect(m_buffer.data(), &BufferInterface::aboutToBeDestroyed, m_buffer.data(), &BufferInterface::unref);
}
}
}