Commit 2f27fc9f authored by Fushan Wen's avatar Fushan Wen Committed by Nate Graham
Browse files

taskmanager: Prevent useless component creation/destruction for grouped tooltips

The binding of "model" property of DelegateModel in ToolTipDelegate.qml
will trigger useless component creation/destruction when "rootIndex" is
changed but is not undefined. Make the ternary operator depend on
"hasRootIndex" bool property to avoid that.

In Task.qml, only assign different values to "parentTask" and "rootIndex"
to avoid unnecessary component creation/destruction for the second time
hovering on the same task.

CCBUG: 433907
CCBUG: 444001


(cherry picked from commit 12373d31)
parent 262665ac
......@@ -335,8 +335,16 @@ MouseArea {
onContainsMouseChanged: {
if (containsMouse) {
mainItem.parentTask = task;
mainItem.rootIndex = tasksModel.makeModelIndex(itemIndex, -1);
// Only assign different values to mainItem to avoid unnecessary reevaluation
if (mainItem.parentTask !== task) {
mainItem.parentTask = task;
}
let rootIndex = tasksModel.makeModelIndex(itemIndex, -1);
if (mainItem.rootIndex !== rootIndex) {
mainItem.rootIndex = rootIndex;
}
mainItem.appName = Qt.binding(function() {
return model.AppName;
......
......@@ -23,6 +23,9 @@ PlasmaComponents3.ScrollView {
property Item parentTask
property var rootIndex
// hasRootIndex is needed to avoid unnecessary reevaluation of model property in DelegateModel,
// because !!toolTipDelegate.rootIndex will not work as expected.
readonly property bool hasRootIndex: !!rootIndex
property string appName
property int pidParent
......@@ -97,7 +100,7 @@ PlasmaComponents3.ScrollView {
Repeater {
id: groupRepeater
model: DelegateModel {
model: toolTipDelegate.rootIndex ? tasksModel : null
model: toolTipDelegate.hasRootIndex ? tasksModel : null
rootIndex: toolTipDelegate.rootIndex
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment