Bug 422672 - New System Monitor widgets: "Apply" button doesn't work as expected after I add or remove a sensor
Summary: New System Monitor widgets: "Apply" button doesn't work as expected after I a...
Status: RESOLVED FIXED
Alias: None
Product: plasmashell
Classification: Plasma
Component: System Monitor (show other bugs)
Version: 5.20.90
Platform: Arch Linux Linux
: NOR normal
Target Milestone: 1.0
Assignee: Marco Martin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-09 13:10 UTC by Patrick Silva
Modified: 2021-03-11 18:24 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.21.3


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Silva 2020-06-09 13:10:23 UTC
SUMMARY
All the new widgets are affected:
individual core usage
total cpu usage
memory usage
network speed
hard disk activity
system monitor sensor

STEPS TO REPRODUCE
1. add any widget mentioned above to your desktop
2. open the widget settings
3. click on "Sensor details" section
4. add or remove any sensor
5. click on "Apply" button: notice that the clicked button remains active
6. click on another section in the left side: unexpeted apply/discard dialog shows up. Click on "Apply" button
7. go back to "Sensor details" section: apply/discard dialog shows up again

EXPECTED RESULT
"Apply" button should become inactive after the step 5.
No apply/discard dialog should appear when we click on another section after the step 5.


SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.19.0
KDE Frameworks Version: 5.70.0
Qt Version: 5.15
Comment 1 JanKusanagi 2020-06-19 22:33:08 UTC
Can reproduce, quite constantly, on Plasma 5.19.1.
Comment 2 wincak 2021-02-16 22:35:03 UTC
I cannot reproduce the described behaviour. After clicking on "Apply" in the dialog (step 6.), changes are saved. However there seems to be a related bug.

The apply button behaves in this way:
1. - 5. The same
6. Click on the widget to open it's pop-up (widget is in tray). Changes are already applied.
7. Click on another section on the left side: apply/discard dialog shows up. Click "Cancel".
8. Click on the "Apply" button again: the button goes inactive.
9. Click on another left side section again. The apply/discard dialog does not show up anymore.

This happens every time. Tested right after upgrading to 5.21.

Operating System: KDE neon 5.21
KDE Plasma Version: 5.21.0
KDE Frameworks Version: 5.79.0
Qt Version: 5.15.2
Kernel Version: 5.4.0-65-generic
OS Type: 64-bit
Graphics Platform: X11
Processors: 4 × Intel® Core™ i7-3520M CPU @ 2.90GHz
Memory: 7,5 GiB of RAM
Graphics Processor: Mesa DRI Intel® HD Graphics 4000
Comment 3 Patrick Silva 2021-02-17 01:54:46 UTC
it's still reproducible.

Operating System: Arch Linux
KDE Plasma Version: 5.21.0
KDE Frameworks Version: 5.79.0
Qt Version: 5.15.2
Comment 4 David Edmundson 2021-03-01 12:09:17 UTC
Indeed. Clicking apply a second time "fixes" it, but that's not ideal.

It appears we call save

that ends up in 
        function onLowPrioritySensorIdsChanged() {
            Qt.callLater(root.loadConfig);
        }

(or one of the matching function)

That calls load

That emits configurationChanged
Comment 5 David Edmundson 2021-03-01 12:25:17 UTC
This was introduced in

```
    reset the page when reloaded
    
    when the dialog gets closed the page parent changes to null
    as well when the active config pages is switched.
    when this appen, reload the config
```

problem is it's also applying on save.
Comment 6 David Edmundson 2021-03-01 14:29:12 UTC
As it is an array

```
cfg_totalSensors = controller.totalSensors;
```

always triggers a change even though the contents of each array is the same.

As a relatively quick fix we can guard all of these in some sort of array comparison function
Comment 7 Bug Janitor Service 2021-03-09 11:54:22 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/libksysguard/-/merge_requests/137
Comment 8 David Edmundson 2021-03-11 14:25:30 UTC
Git commit 0c0e4af86c9cf4b91f219399c3465fe272036891 by David Edmundson.
Committed on 11/03/2021 at 14:05.
Pushed by davidedmundson into branch 'master'.

Avoid emitting configurationChanged during save

The system montior widgets have a 3 way-sync between it's own internal
saving mechanism and external cfg properties purely for the apply
button. This leads to us calling load just after save when values sync,
and because JS can't compare arrays easily this leads to us emitting the
config has changes again immediately.

M  +28   -11   faces/ConfigSensors.qml

https://invent.kde.org/plasma/libksysguard/commit/0c0e4af86c9cf4b91f219399c3465fe272036891
Comment 9 David Edmundson 2021-03-11 14:25:57 UTC
Git commit ace8d824a5d2b9793c1d8c59d0191005fb38e4e9 by David Edmundson.
Committed on 11/03/2021 at 14:25.
Pushed by davidedmundson into branch 'Plasma/5.21'.

Avoid emitting configurationChanged during save

The system montior widgets have a 3 way-sync between it's own internal
saving mechanism and external cfg properties purely for the apply
button. This leads to us calling load just after save when values sync,
and because JS can't compare arrays easily this leads to us emitting the
config has changes again immediately.


(cherry picked from commit 0c0e4af86c9cf4b91f219399c3465fe272036891)

M  +28   -11   faces/ConfigSensors.qml

https://invent.kde.org/plasma/libksysguard/commit/ace8d824a5d2b9793c1d8c59d0191005fb38e4e9