Synchronise setNeedsSave between KCModule and ConfigModule in both directions
Needs ReviewPublic

Authored by davidedmundson on Feb 28 2020, 4:06 PM.

Details

Reviewers
ervin
Summary

The problem occurs in the following situation:

Widgets and such often change state and emit they're changed on the
initial load. This is typically a bug, but easy to hit and hard to find.

To resolve this KCModule::showEvent() queues up a
KCModule::changed(false) after loading. It hides the problem for
widgets.

This ends up causing a bigger problem for the QML side.

If during load ConfigModule::setNeedsSave(true) is called we set
d->_needsSave to true
We emit ConfigModule::changed(true) which we proxy through to
KCModule::changed(true)

We then process the queued KCModule::setChanged(false) from the earlier
KCModule::showEvent so we disable the button

But problematically any subsequent changes in the KCM which call
ConfigModule::setNeedsSave(true) now no-op and don't get proxied.

This patch resolves the issue by keeping the syncronisation between
KCModule and ConfigModule working in both directions.

It is an alternative to D27452. It's not as neat but it's safer.

BUG: 411584

Diff Detail

Repository
R295 KCMUtils
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 24130
Build 24148: arc lint + arc unit
davidedmundson created this revision.Feb 28 2020, 4:06 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptFeb 28 2020, 4:06 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
davidedmundson requested review of this revision.Feb 28 2020, 4:06 PM
crossi added a subscriber: crossi.Feb 28 2020, 4:33 PM
davidedmundson edited the summary of this revision. (Show Details)Mar 2 2020, 12:49 PM

Tested as an alternative to D27944
At initialization, the apply button is enabled.
Unfortunately, if the user clicks on reset button at first, the apply button is disabled an stays disabled.

meven added a subscriber: meven.Mar 13 2020, 8:47 AM
meven added inline comments.
src/kcmoduleqml.cpp
87

s/extermally/externally

ervin requested changes to this revision.Mar 16 2020, 3:39 PM
ervin added a subscriber: ervin.

What @meven said about the typo, otherwise LGTM indeed.

This revision now requires changes to proceed.Mar 16 2020, 3:39 PM
davidedmundson marked an inline comment as done.Mar 24 2020, 12:28 AM

Unfortunately, if the user clicks on reset button at first, the apply button is disabled an stays disabled.

I'm not sure I understand why that would happen.

That means there's something else going on, and we shouldn't ship this till we understand it.

davidedmundson retitled this revision from Syncronise setNeedsSave between KCModule and ConfigModule in both directions to Synchronise setNeedsSave between KCModule and ConfigModule in both directions.Mar 24 2020, 12:31 AM

Unfortunately, if the user clicks on reset button at first, the apply button is disabled an stays disabled.

I'm not sure I understand why that would happen.

That means there's something else going on, and we shouldn't ship this till we understand it.

I don't understand either but I didn't investigate deeper.
From what I have tested, it does not keep in sync setNeedsSave state.