Skip to content
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

Merged
merged 4 commits into from Jan 28, 2023
Merged

Fix LoopStatus errors #16

merged 4 commits into from Jan 28, 2023

Conversation

llewelld
Copy link
Member

@llewelld llewelld commented Jan 17, 2023

  1. 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.
  2. Send correct LoopStatus values. Send "None", "Track" and "Playlist" instead of "LoopNone", "LoopTrack" and "LoopPlaylist" for the LoopStatus values.
  3. 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.
  4. 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.

@llewelld llewelld marked this pull request as draft January 17, 2023 22:16
src/mpris.cpp Outdated Show resolved Hide resolved
src/mpris.cpp Outdated Show resolved Hide resolved
@llewelld llewelld force-pushed the jb59853 branch 4 times, most recently from f1639b0 to a88a16e Compare January 20, 2023 07:58
@llewelld llewelld marked this pull request as ready for review January 20, 2023 08:06
@llewelld llewelld requested review from inzanity, Tomin1 and abranson and removed request for inzanity January 20, 2023 08:06
{
// The property was not found
m_playerPrivate->sendErrorReply(QDBusError::UnknownProperty,
QString::fromLatin1("Property %1%2%3 was not found in object %4")
Copy link
Contributor

@inzanity inzanity Jan 20, 2023

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.

Copy link
Member Author

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()) {
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Member

@Tomin1 Tomin1 left a 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.

src/mpris.cpp Outdated Show resolved Hide resolved
src/mprisplayer_p.h Outdated Show resolved Hide resolved
src/mprispropertiesadaptor.cpp Show resolved Hide resolved
src/mprispropertiesadaptor.cpp Outdated Show resolved Hide resolved
src/mpris.cpp Outdated Show resolved Hide resolved
Copy link
Member

@Tomin1 Tomin1 left a 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. 👍

src/mprispropertiesadaptor.cpp Outdated Show resolved Hide resolved
src/mprispropertiesadaptor.cpp Outdated Show resolved Hide resolved
src/mprispropertiesadaptor.cpp Outdated Show resolved Hide resolved
src/mprispropertiesadaptor.cpp Outdated Show resolved Hide resolved
src/mprispropertiesadaptor.cpp Outdated Show resolved Hide resolved
@Tomin1
Copy link
Member

Tomin1 commented Jan 25, 2023

One more thing, one of the commit messages has title:

[mpris] Send correct LoopStatus values. Fixes JB59854

That is missing # character.

llewelld and others added 4 commits January 25, 2023 17:00
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.
@llewelld
Copy link
Member Author

That is missing # character.

Thanks for your careful review Tomi. I've fixed the commit message too.

@llewelld llewelld merged commit 588ee25 into master Jan 28, 2023
@Tomin1 Tomin1 deleted the jb59853 branch March 31, 2023 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants