Create an empty config (.e.g ~/.gtkrc-2.0) if none exists
ClosedPublic

Authored by heikobecker on Sep 19 2019, 3:22 PM.

Details

Summary

After a9f3a3d saveSettingsPrivate() errors out if the config file
doesn't exist. This is because QFile::open(QIODevice::ReadOnly... )
doesn't create a new file for non-existant filenames, like the
same invocation with the previously used QIODevice::WriteOnly does.

I'm not sure how likely the absence of the config file is, but it's
easy to recover from by creating an empty file first. We're trying
to save our settings afterwards anyway.

A place there this problem occurred is the configsave unit test. The
filenames passed in ConfigSaveTest::testGtk2 don't exist when running
the test, causing it to fail without this patch.

Test Plan
  • Moved ~/.gtkrc-2.0 out of the way, ran kcmshell5 kde-gtk-config, saving didn't error out
  • make test passes again

Diff Detail

Repository
R99 KDE Gtk Configuration Tool
Branch
Plasma/5.17
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 16802
Build 16820: arc lint + arc unit
heikobecker created this revision.Sep 19 2019, 3:22 PM
Restricted Application added a project: Plasma. · View Herald TranscriptSep 19 2019, 3:22 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
heikobecker requested review of this revision.Sep 19 2019, 3:22 PM
heikobecker edited the test plan for this revision. (Show Details)Sep 19 2019, 3:23 PM
heikobecker added a reviewer: gikari.
ngraham accepted this revision.Sep 19 2019, 4:06 PM
ngraham added a subscriber: ngraham.

LGTM but let's see what @apol thinks.

This revision is now accepted and ready to land.Sep 19 2019, 4:06 PM
gikari added inline comments.Sep 19 2019, 5:46 PM
src/appearancegtk2.cpp
90

I think file creation could be simplified. Just replace WriteOnly flag with ReadWrite here. This would mean, that file will be created automatically if it doesn't exist. If you think intention to open file also for write is unclear, write a comment alongside.

Used the ReadWrite flag to simplify

heikobecker marked an inline comment as done.Sep 19 2019, 6:21 PM
gikari accepted this revision.Sep 19 2019, 6:25 PM
This revision was automatically updated to reflect the committed changes.