New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix LoopStatus errors #16
Conversation
llewelld
commented
Jan 17, 2023
•
edited
edited
- Return DBus errors for incorrect Set parameters: Fixes a SIGSEGV when incorrect parameters were passed when setting LoopStatus and PlaybackStatus via DBus. Provides a separate DBus interface for org.freedesktop.DBus.Properties rather than using the automatic interface, so that errors can be returned when these invalid values are Set.
- Send correct LoopStatus values. Send "None", "Track" and "Playlist" instead of "LoopNone", "LoopTrack" and "LoopPlaylist" for the LoopStatus values.
- Use enums internally for LoopStatus and playbackStatus. Rather than storing the loopStatus and playbackStatus as QStrings, this uses the enums internally to ensure valid values are always maintained.
- Update canControl at initialisation. Ensures that canControl emits a change signal in case it switches from false (the default) to true during initialisation. Otherwise clients won't notice that it's changed.
f1639b0
to
a88a16e
Compare
| { | ||
| // The property was not found | ||
| m_playerPrivate->sendErrorReply(QDBusError::UnknownProperty, | ||
| QString::fromLatin1("Property %1%2%3 was not found in object %4") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess QStringLiteral would be the best choice here.
Although, this is the error path, so the binary size vs performance might lean towards binary size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I guess you're right: the choice here is between an extra run-time Latin1 -> UTF-16 conversion, and doubling the string size in the binary.
I think this approach here is okay; it's used quite widely elsewhere, e.g. in Qt itself
| } | ||
|
|
||
| const QString &getter = getMap.value(property_name); | ||
| if (!getter.isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think .isNull() would be the most correct check, but this works just as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that it should happen, but this is intended to capture "" entries in the map as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments. I need to come back to this still though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had some style related comments to check but otherwise looks good to me and AFAICT it also works. 👍
|
One more thing, one of the commit messages has title:
That is missing |
Fixes a SIGSEGV when incorrect parameters were passed when setting LoopStatus and PlaybackStatus via DBus. Provides a separate DBus interface for org.freedesktop.DBus.Properties rather than using the automatic interface, so that errors can be returned when these invalid values are Set.
Send "None", "Track" and "Playlist" instead of "LoopNone", "LoopTrack" and "LoopPlaylist" for the LoopStatus values.
… JB#59562 Rather than storing the loopStatus and playbackStatus as QStrings, this uses the enums internally to ensure valid values are always maintained. Note that this will change the behaviour a little as now setting an invalid value does not result in change at all. Previously it would have set the value as is and made the library effectively use a default value. Internal functions access the values directly through internal getters and setters. Co-authored-by: Tomi Leppänen <tomi.leppanen@jolla.com>
Ensures that canControl emits a change signal in case it switches from false (the default) to true during initialisation. Otherwise clients won't notice that it's changed.
Thanks for your careful review Tomi. I've fixed the commit message too. |