FrameSvg: make hasElementPrefix() also handle prefix with trailing -
ClosedPublic

Authored by kossebau on May 12 2019, 11:41 PM.

Details

Summary

there are a few places which potentially pass a prefix with a trailing -,
e.g. if using directly the value of FrameSvg::prefix() or
FrameSvg::actualPrefix(). Support the assumption in such code, unbreaking
its currently not working behaviour.

Diff Detail

Repository
R242 Plasma Framework (Library)
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
kossebau created this revision.May 12 2019, 11:41 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptMay 12 2019, 11:41 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
kossebau requested review of this revision.May 12 2019, 11:41 PM

The other option would be to fix the places which call hasElementPrefix but given that the ones known all rely on prefix() and actualPrefix(), it seems less code to fix this in one place and change behaviour a bit to be more grateful with the argument passed.

apol added a subscriber: apol.May 13 2019, 11:23 AM
apol added inline comments.
src/plasma/framesvg.cpp
150

else? or we want to test --center if -center fails?

kossebau added inline comments.May 13 2019, 1:05 PM
src/plasma/framesvg.cpp
150

How would you use the else? Not yet with you what you mean here,

apol added inline comments.May 13 2019, 2:32 PM
src/plasma/framesvg.cpp
150
if (prefix.endsWith(QLatin1Char('-'))) {
    return hasElement(prefix % QLatin1String("center"));
} else
    return hasElement(prefix % QLatin1String("-center"));
kossebau added inline comments.May 13 2019, 2:38 PM
src/plasma/framesvg.cpp
150

But given the return, if the else needed? Actually some people recommend to not use else after return. I might be Monday blind, sorry :)

apol added inline comments.May 13 2019, 3:17 PM
src/plasma/framesvg.cpp
150

I guess it doesn't matter. :)

kossebau updated this revision to Diff 58040.May 13 2019, 10:42 PM

Be verbose about behavioural adaption in API dox

mart accepted this revision.May 14 2019, 1:57 PM
This revision is now accepted and ready to land.May 14 2019, 1:57 PM
This revision was automatically updated to reflect the committed changes.