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)

commit5e60e02f3f6e35e793ed104045adcecb9a6e6d84 authorAlbert Astals Cid <albert.astals@canonical.com> dateMon 22 Aug 2016, 17:34 (10 years ago) parent80d42a8
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+ // 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; });