on xenial help sign in
Reduce calls to CardCreatorCache.getCardComponent while the component is being created

As it is right now on the phone we do calls with empty cardTool.artShapeStyle and cardTool.categoryLayout that are useless so protect against it to save time. This is not reproducible on the desktop (there's a different Qt though 5.6 vs 5.4) (LP: #1615675) Approved by: Andrea Cimitan

commitc196a3dfd8052c709a8b187a70264f2724dd6f35 authorAlbert Astals Cid <albert.astals@canonical.com> dateWed 14 Sep 2016, 00:35 (10 years ago) parentc7951cc3ad50e3
1 file changed+14−2
qml/Dash/CardTool.qml+14−2
qml/Dash/CardTool.qml+14−2
@@ -71,7 +71,17 @@ Item {
7171 // Not readonly because gets overwritten from GenericScopeView in some cases
7272 property string artShapeStyle: categoryLayout === "carousel" ? "shadow" : "inset"
7373
74− property var cardComponent: CardCreatorCache.getCardComponent(cardTool.template, cardTool.components, false, cardTool.artShapeStyle, cardTool.categoryLayout);
74+ // FIXME ? This seems like it should not be needed, but on Qt 5.4 + phone
75+ // we are doing unneeded calls to getCardComponent with artShapeStyle and categoryLayout being empty
76+ // Check when we move to newer Qts on the phone if we still need this
77+ readonly property bool askForCardComponent: cardTool.template !== undefined &&
78+ cardTool.components !== undefined &&
79+ cardTool.artShapeStyle !== "" &&
80+ cardTool.categoryLayout !== ""
81+
82+ property var cardComponent: askForCardComponent
83+ ? CardCreatorCache.getCardComponent(cardTool.template, cardTool.components, false, cardTool.artShapeStyle, cardTool.categoryLayout)
84+ : undefined
7585
7686 // FIXME: Saviq
7787 // Only way for the card below to actually be laid out completely.
@@ -213,7 +223,9 @@ Item {
213223 "attributes": attributesModel.model,
214224 "socialActions": socialActionsModel.model
215225 }
216− sourceComponent: CardCreatorCache.getCardComponent(cardTool.template, cardTool.components, true, cardTool.artShapeStyle, cardTool.categoryLayout);
226+ sourceComponent: askForCardComponent
227+ ? CardCreatorCache.getCardComponent(cardTool.template, cardTool.components, true, cardTool.artShapeStyle, cardTool.categoryLayout)
228+ : undefined
217229 onLoaded: {
218230 item.objectName = "cardToolCard";
219231 item.width = Qt.binding(function() { return cardTool.cardWidth !== -1 ? cardTool.cardWidth : item.implicitWidth; });