Avoid capturing MenuItem instead determine checked state from toggled signal
ClosedPublic

Authored by davidedmundson on Feb 24 2017, 1:53 PM.

Details

Summary

Due to JS lambdas menuItem is being captured by reference, and as such
the call to menuItem.checked returns the checked state of the last item
in the for loop. Instead of adding to the capture this patch uses the
supplied boolean from the QMenuItem::toggled signal.

Also unlike Array.concat Array.splice alters the current array, we don't
want to create a new var.

BUG: 376826

Test Plan

Debug of menuItem.text showed we were capturing the wrong thing
Clicked window into multiple activities and unticked them. All worked as intended

Diff Detail

Repository
R119 Plasma Desktop
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
davidedmundson created this revision.Feb 24 2017, 1:53 PM
Restricted Application added a project: Plasma. · View Herald TranscriptFeb 24 2017, 1:53 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
broulik accepted this revision.Feb 24 2017, 2:04 PM
broulik added a subscriber: broulik.

Also unlike Array.concat Array.splice alters the current array, we don't want to create a new var.

The return value of splice is btw the items that were removed.

applets/taskmanager/package/contents/ui/ContextMenu.qml
378

You could have passed the correct menuItem in here just like it's already done correctly with activityId

This revision is now accepted and ready to land.Feb 24 2017, 2:04 PM
This revision was automatically updated to reflect the committed changes.