[outline] Use QScopedPointer for created QML item
According to the documentation the ownership of a QObject created by QQmlComponent::create is transferred to the caller. This fixes a crash on KWin tear down.
This commit is contained in:
parent
645e1cf775
commit
0bf9ed5317
2 changed files with 4 additions and 4 deletions
|
@ -126,7 +126,7 @@ CompositedOutlineVisual::CompositedOutlineVisual(Outline *outline)
|
||||||
: OutlineVisual(outline)
|
: OutlineVisual(outline)
|
||||||
, m_qmlContext()
|
, m_qmlContext()
|
||||||
, m_qmlComponent()
|
, m_qmlComponent()
|
||||||
, m_mainItem(nullptr)
|
, m_mainItem()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ CompositedOutlineVisual::~CompositedOutlineVisual()
|
||||||
|
|
||||||
void CompositedOutlineVisual::hide()
|
void CompositedOutlineVisual::hide()
|
||||||
{
|
{
|
||||||
if (QQuickWindow *w = qobject_cast<QQuickWindow*>(m_mainItem)) {
|
if (QQuickWindow *w = qobject_cast<QQuickWindow*>(m_mainItem.data())) {
|
||||||
w->hide();
|
w->hide();
|
||||||
w->destroy();
|
w->destroy();
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ void CompositedOutlineVisual::show()
|
||||||
if (m_qmlComponent->isError()) {
|
if (m_qmlComponent->isError()) {
|
||||||
qDebug() << "Component failed to load: " << m_qmlComponent->errors();
|
qDebug() << "Component failed to load: " << m_qmlComponent->errors();
|
||||||
} else {
|
} else {
|
||||||
m_mainItem = m_qmlComponent->create(m_qmlContext.data());
|
m_mainItem.reset(m_qmlComponent->create(m_qmlContext.data()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ public:
|
||||||
private:
|
private:
|
||||||
QScopedPointer<QQmlContext> m_qmlContext;
|
QScopedPointer<QQmlContext> m_qmlContext;
|
||||||
QScopedPointer<QQmlComponent> m_qmlComponent;
|
QScopedPointer<QQmlComponent> m_qmlComponent;
|
||||||
QObject *m_mainItem;
|
QScopedPointer<QObject> m_mainItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
class NonCompositedOutlineVisual : public OutlineVisual
|
class NonCompositedOutlineVisual : public OutlineVisual
|
||||||
|
|
Loading…
Reference in a new issue