diff --git a/plugins/findthisdevice/findthisdevice_config.cpp b/plugins/findthisdevice/findthisdevice_config.cpp index d9a77a6b9..6971f7e07 100644 --- a/plugins/findthisdevice/findthisdevice_config.cpp +++ b/plugins/findthisdevice/findthisdevice_config.cpp @@ -74,16 +74,18 @@ void FindThisDeviceConfig::save() void FindThisDeviceConfig::playSound() { - const QString soundFile = m_ui->soundFileRequester->text(); - - QUrl soundURL = QUrl(soundFile); - QMediaPlayer* player = new QMediaPlayer; - player->setAudioRole(QAudio::Role(QAudio::NotificationRole)); - player->setMedia(soundURL); - player->setVolume(100); - player->play(); - connect(player, &QMediaPlayer::stateChanged, player, &QObject::deleteLater); + const QUrl soundURL = m_ui->soundFileRequester->url(); + if (soundURL.isEmpty()) { + qCWarning(KDECONNECT_PLUGIN_FINDTHISDEVICE) << "Not playing sound, no valid ring tone specified."; + } else { + QMediaPlayer* player = new QMediaPlayer; + player->setAudioRole(QAudio::Role(QAudio::NotificationRole)); + player->setMedia(soundURL); + player->setVolume(100); + player->play(); + connect(player, &QMediaPlayer::stateChanged, player, &QObject::deleteLater); + } }