Commit 18aa8bea authored by kgr@chromium.org's avatar kgr@chromium.org

Fix for "removing tasks can change row selection" bug.


BUG=115171
TEST=See repro steps in bug report.

Review URL: http://codereview.chromium.org/9570028

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124945 0039d316-1c4b-4281-b951-d872f2087c98
parent 36478248
......@@ -542,18 +542,30 @@ TaskManager.prototype = {
var length = task.length;
var tasks = task.tasks;
// We have to store the selected indexes and restore them after
// We have to store the selected pids and restore them after
// splice(), because it might replace some items but the replaced
// items would lose the selection.
var oldSelectedIndexes = sm.selectedIndexes;
// Create map of selected PIDs.
var selectedPids = {};
for (var i = 0; i < oldSelectedIndexes.length; i++) {
var item = dm.item(oldSelectedIndexes[i]);
if (item) selectedPids[item['processId'][0]] = true;
}
var args = tasks.slice();
args.unshift(start, dm.length);
dm.splice.apply(dm, args);
sm.selectedIndexes = oldSelectedIndexes.filter(function(index) {
return index < dm.length;
});
// Create new array of selected indexes from map of old PIDs.
var newSelectedIndexes = [];
for (var i = 0; i < dm.length; i++) {
if (selectedPids[dm.item(i)['processId'][0]])
newSelectedIndexes.push(i);
}
sm.selectedIndexes = newSelectedIndexes;
var pids = [];
for (var i = 0; i < dm.length; i++) {
......
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