Fix crash if swtichSize is adjusted during initial setup

This causes us to create components and items during the initial binding
evaluation of the root.

Reviewed-by: Marco Martin
This commit is contained in:
David Edmundson 2019-07-17 11:57:40 +02:00
parent 05daa3e206
commit 03d406770f
2 changed files with 7 additions and 0 deletions

View File

@ -51,6 +51,7 @@ AppletQuickItemPrivate::AppletQuickItemPrivate(Plasma::Applet *a, AppletQuickIte
: q(item),
switchWidth(-1),
switchHeight(-1),
initComplete(false),
applet(a),
expanded(false),
activationTogglesExpanded(false)
@ -342,6 +343,10 @@ void AppletQuickItemPrivate::preloadForExpansion()
void AppletQuickItemPrivate::compactRepresentationCheck()
{
if (!initComplete) {
return;
}
if (!qmlObject->rootObject()) {
return;
}
@ -669,6 +674,7 @@ void AppletQuickItem::init()
d->compactRepresentationExpander->loadUrl(compactExpanderUrl);
}
d->initComplete = true;
d->compactRepresentationCheck();
qmlObject()->engine()->rootContext()->setBaseUrl(qmlObject()->source());
qmlObject()->engine()->setContextForObject(this, qmlObject()->engine()->rootContext());

View File

@ -132,6 +132,7 @@ public:
bool expanded : 1;
bool activationTogglesExpanded : 1;
bool initComplete: 1;
static QHash<QObject *, AppletQuickItem *> s_rootObjects;
};