Ref KConfig whilst we're using it
AbandonedPublic

Authored by davidedmundson on Jun 18 2018, 10:43 AM.

Details

Reviewers
None
Group Reviewers
Plasma
Summary

In current code we would have a KConfigGroup with a dangling KConfig
deleted after the RHS for the group fetch has finished.

BUG: 394534

Test Plan

Wrote minimal test case of code
It produced a valgrind warning (weirdly didn't crash though)
Modified to correct version
No longer any warnings

Diff Detail

Repository
R119 Plasma Desktop
Branch
davidedmundson/kcm_clock_qml
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 85
Build 85: arc lint + arc unit
Restricted Application added a project: Plasma. · View Herald TranscriptJun 18 2018, 10:43 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
davidedmundson requested review of this revision.Jun 18 2018, 10:43 AM
fvogt added a subscriber: fvogt.Jun 18 2018, 12:23 PM

I guess KSharedConfig would work as well, that way the KConfig keeps a reference alive.

fvogt added a comment.Jun 18 2018, 1:36 PM

Could this have any relationship to https://bugs.kde.org/show_bug.cgi?id=395401?

In theory yes, this is undefined behaviour and could cause everything between making a pixel slightly darker or crashing the harddrive.

In practice I doubt it - this doesn't touch any of the code related to saving.

I guess KSharedConfig would work as well, that way the KConfig keeps a reference alive.

I'm not convinced that

auto group = KSharedConfig::openConfig().group()
would be any different.

Your shared pointer still goes out of scope, the group's handle to the kconfig object is still the same.

but I can change anyway

fvogt added a comment.Jun 19 2018, 8:06 AM

Your shared pointer still goes out of scope, the group's handle to the kconfig object is still the same.

If I read the code correctly, the group keeps the shared pointer, which means it owns a reference.

wbauer added a subscriber: wbauer.Jun 19 2018, 8:36 AM

Could this have any relationship to https://bugs.kde.org/show_bug.cgi?id=395401?

In theory yes, this is undefined behaviour and could cause everything between making a pixel slightly darker or crashing the harddrive.

In practice I doubt it - this doesn't touch any of the code related to saving.

But that bug is about the settings not being applied on login.
Comment#0 says that the settings are in fact saved correctly.