[kwin/aurorae] Have the QMutex in the Factory and not in each Client
This seems to fix the crash which could happen when closing a window. At least the kwindowsystem unit tests no longer crash KWin (it was very reliable before). BUG: 332091
This commit is contained in:
parent
086bc69ec5
commit
cdd9c5bcf5
2 changed files with 8 additions and 4 deletions
|
@ -51,6 +51,7 @@ AuroraeFactory::AuroraeFactory(QObject *parent)
|
||||||
, m_engine(new QQmlEngine(this))
|
, m_engine(new QQmlEngine(this))
|
||||||
, m_component(new QQmlComponent(m_engine, this))
|
, m_component(new QQmlComponent(m_engine, this))
|
||||||
, m_engineType(AuroraeEngine)
|
, m_engineType(AuroraeEngine)
|
||||||
|
, m_mutex(new QMutex(QMutex::Recursive))
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
connect(options(), &KDecorationOptions::buttonsChanged, this, &AuroraeFactory::buttonsChanged);
|
connect(options(), &KDecorationOptions::buttonsChanged, this, &AuroraeFactory::buttonsChanged);
|
||||||
|
@ -245,7 +246,6 @@ AuroraeClient::AuroraeClient(KDecorationBridge *bridge, KDecorationFactory *fact
|
||||||
: KDecoration(bridge, factory)
|
: KDecoration(bridge, factory)
|
||||||
, m_view(nullptr)
|
, m_view(nullptr)
|
||||||
, m_item(AuroraeFactory::instance()->createQmlDecoration(this))
|
, m_item(AuroraeFactory::instance()->createQmlDecoration(this))
|
||||||
, m_mutex(new QMutex(QMutex::Recursive))
|
|
||||||
{
|
{
|
||||||
connect(AuroraeFactory::instance(), SIGNAL(buttonsChanged()), SIGNAL(buttonsChanged()));
|
connect(AuroraeFactory::instance(), SIGNAL(buttonsChanged()), SIGNAL(buttonsChanged()));
|
||||||
connect(AuroraeFactory::instance(), SIGNAL(configChanged()), SIGNAL(configChanged()));
|
connect(AuroraeFactory::instance(), SIGNAL(configChanged()), SIGNAL(configChanged()));
|
||||||
|
@ -282,7 +282,7 @@ void AuroraeClient::init()
|
||||||
m_view->setRenderTarget(m_fbo.data());
|
m_view->setRenderTarget(m_fbo.data());
|
||||||
});
|
});
|
||||||
connect(m_view, &QQuickWindow::afterRendering, [this]{
|
connect(m_view, &QQuickWindow::afterRendering, [this]{
|
||||||
QMutexLocker locker(m_mutex.data());
|
QMutexLocker locker(AuroraeFactory::instance()->mutex());
|
||||||
m_buffer = m_fbo->toImage();
|
m_buffer = m_fbo->toImage();
|
||||||
});
|
});
|
||||||
connect(m_view, &QQuickWindow::afterRendering, this,
|
connect(m_view, &QQuickWindow::afterRendering, this,
|
||||||
|
@ -563,7 +563,7 @@ bool AuroraeClient::animationsSupported() const
|
||||||
|
|
||||||
void AuroraeClient::render(QPaintDevice *device, const QRegion &sourceRegion)
|
void AuroraeClient::render(QPaintDevice *device, const QRegion &sourceRegion)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(m_mutex.data());
|
QMutexLocker locker(AuroraeFactory::instance()->mutex());
|
||||||
QPainter painter(device);
|
QPainter painter(device);
|
||||||
painter.setClipRegion(sourceRegion);
|
painter.setClipRegion(sourceRegion);
|
||||||
painter.drawImage(QPoint(0, 0), m_buffer);
|
painter.drawImage(QPoint(0, 0), m_buffer);
|
||||||
|
|
|
@ -57,6 +57,10 @@ public:
|
||||||
return m_themeName;
|
return m_themeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QMutex *mutex() {
|
||||||
|
return m_mutex.data();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum EngineType {
|
enum EngineType {
|
||||||
AuroraeEngine,
|
AuroraeEngine,
|
||||||
|
@ -83,6 +87,7 @@ private:
|
||||||
QQmlComponent *m_component;
|
QQmlComponent *m_component;
|
||||||
EngineType m_engineType;
|
EngineType m_engineType;
|
||||||
QString m_themeName;
|
QString m_themeName;
|
||||||
|
QScopedPointer<QMutex> m_mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AuroraeClient : public KDecoration
|
class AuroraeClient : public KDecoration
|
||||||
|
@ -162,7 +167,6 @@ private:
|
||||||
QScopedPointer<QQuickItem> m_item;
|
QScopedPointer<QQuickItem> m_item;
|
||||||
QScopedPointer<QOpenGLFramebufferObject> m_fbo;
|
QScopedPointer<QOpenGLFramebufferObject> m_fbo;
|
||||||
QImage m_buffer;
|
QImage m_buffer;
|
||||||
QScopedPointer<QMutex> m_mutex;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue