The docs say that QMediaPlaylist::addMedia returns false if it fails:
bool QMediaPlaylist::addMedia(const QMediaContent & content) Append the media content to the playlist. Returns true if the operation is successful, otherwise return false.
But this code will print true even though the file doesn't exist:
QMediaPlayer *player = new QMediaPlayer;
QMediaPlaylist *playlist = new QMediaPlaylist(player);
qDebug() << playlist->addMedia(QUrl("this file doesn't exist.mp4"));
If the file doesn't exist how can the operation be considered successful?
After stepping into the Qt sources, I saw that QMediaPlaylist::addMedia() calls
QMediaNetworkPlaylistProvider::addMedia()
, which always returns true:Although why it needs to return a bool that's always true is a mystery to me.