~ci-train-bot/media-hub/media-hub-ubuntu-yakkety-landing-056

« back to all changes in this revision

Viewing changes to src/core/media/player_implementation.cpp

  • Committer: Bileto Bot
  • Author(s): Jim Hodapp
  • Date: 2016-06-23 00:22:55 UTC
  • mfrom: (184.1.13 media-hub)
  • Revision ID: ci-train-bot@canonical.com-20160623002255-jvu6ehaqbxsnb5xh
Make sure to not crash when the current track is not set. (LP: #1594524)

Show diffs side-by-side

added added

removed removed

Lines of Context:
391
391
        media::Track::MetaData metadata{md};
392
392
        if (not metadata.is_set(media::Track::MetaData::TrackIdKey))
393
393
        {
394
 
            const std::size_t last_slash = track_list->current().find_last_of("/");
395
 
            const std::string track_id = track_list->current().substr(last_slash+1);
396
 
            if (not track_id.empty())
397
 
                metadata.set_track_id("/org/mpris/MediaPlayer2/Track/" + track_id);
 
394
            const std::string current_track = track_list->current();
 
395
            if (not current_track.empty())
 
396
            {
 
397
                const std::size_t last_slash = current_track.find_last_of("/");
 
398
                const std::string track_id = current_track.substr(last_slash + 1);
 
399
                if (not track_id.empty())
 
400
                    metadata.set_track_id("/org/mpris/MediaPlayer2/Track/" + track_id);
 
401
                else
 
402
                    MH_WARNING("Failed to set MPRIS track id since the id value is NULL");
 
403
            }
398
404
            else
399
405
                MH_WARNING("Failed to set MPRIS track id since the id value is NULL");
400
406
        }