libkwineffects: Make SceneEffect fallback to root context
QuickSceneEffect can also be instantiated by C++, for example that's the case with the overview effect. In that case, qmlContext() is not going to return a valid context because the effect has not been created by a QQmlEngine. In that case, use the root context as the parent context.
This commit is contained in:
parent
aa57e9130b
commit
2c29dfd596
1 changed files with 9 additions and 2 deletions
|
@ -439,8 +439,15 @@ void QuickSceneEffect::addScreen(EffectScreen *screen)
|
|||
});
|
||||
incubator->setInitialProperties(properties);
|
||||
|
||||
QQmlContext *creationContext = d->delegate->creationContext();
|
||||
QQmlContext *context = new QQmlContext(creationContext ? creationContext : qmlContext(this));
|
||||
QQmlContext *parentContext;
|
||||
if (QQmlContext *context = d->delegate->creationContext()) {
|
||||
parentContext = context;
|
||||
} else if (QQmlContext *context = qmlContext(this)) {
|
||||
parentContext = context;
|
||||
} else {
|
||||
parentContext = d->delegate->engine()->rootContext();
|
||||
}
|
||||
QQmlContext *context = new QQmlContext(parentContext);
|
||||
|
||||
d->contexts[screen].reset(context);
|
||||
d->incubators[screen].reset(incubator);
|
||||
|
|
Loading…
Reference in a new issue