startplasma: Sort environment scripts prior to sourcing
ClosedPublic

Authored by auxym on Apr 18 2020, 1:37 PM.

Details

Summary

Sort environment scripts before they are sourced. User scripts should run after system scripts to ensure that user preferences take precendence over system defaults. Scripts in each location (user and system) are then separately sorted in lexical order to ensure deterministic source order.

BUG: 420085
FIXED-IN: 5.19.0

Diff Detail

Repository
R120 Plasma Workspace
Lint
Lint Skipped
Unit
Unit Tests Skipped
auxym created this revision.Apr 18 2020, 1:37 PM
Restricted Application added a project: Plasma. · View Herald TranscriptApr 18 2020, 1:37 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
auxym requested review of this revision.Apr 18 2020, 1:37 PM

Concept makes sense.

QStandardPaths is ordered: "The list of directories is sorted from high to low priority, starting with writableLocation()"

so we can cut this code in half by doing some sort of

void runEnvironmentScripts()
{
 const auto locations = QStandardPaths::....
 locations.reverse();
 for (const QString &location:locations) {
    runScriptsInDir(location)
  }
}

void runScriptsInDir(const QString &dir)
{
        QDir dir(location);
...
        std::sort(
...
}

which will keep addition XDG_CONFIG_DIRS in the right order too
auxym added a comment.Apr 18 2020, 6:24 PM

Good option, I had not noticed that in the QT docs. I felt using startsWith() was a bit hackish anyways. Plus, since entryInfoList() has a sort param, I won't even need the sort call.

auxym updated this revision to Diff 80510.Apr 18 2020, 11:34 PM

Use priority as returned by QStandardPaths::standardLocations and sort in the entryInfoList() call.

auxym updated this revision to Diff 80511.Apr 18 2020, 11:40 PM

Fix a comment

apol accepted this revision.Apr 19 2020, 3:14 PM
This revision is now accepted and ready to land.Apr 19 2020, 3:14 PM
cfeck added a subscriber: cfeck.Apr 28 2020, 6:38 AM

It looks like the submitter doesn't have commit rights.

ngraham edited the summary of this revision. (Show Details)Apr 28 2020, 1:50 PM
This revision was automatically updated to reflect the committed changes.

Thanks for the ping, @cfeck. And thanks for the patch @auxym! May it be the first of many. :)