Skip to content

Commit

Permalink
6592 invalid sound path results in crash (#6593)
Browse files Browse the repository at this point in the history
* Fixed expected QObject on throw

* Ensure absolute paths exist

* Updated changelog

---------

Co-authored-by: Olivier Michel <Olivier.Michel@cyberbotics.com>
  • Loading branch information
gabryelreyes and omichel authored Jul 29, 2024
1 parent 0c44a3d commit 9902e0b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/reference/changelog-r2024.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ Released on December **th, 2023.
- Fixed handling of device objects with the same name in the controller API ([#6579](https://github.com/cyberbotics/webots/pull/6579)).
- Fixed crashes (with some graphics cards) caused by references to unused GLSL uniforms ([#6587](https://github.com/cyberbotics/webots/pull/6587)).
- Fixed `Brake`s added to the second axis of a `Hinge2Joint` being applied to the non-transformed axis ([#6584](https://github.com/cyberbotics/webots/pull/6584)).
- Fixed invalid absolute sound file path resulted in crash ([#6593](https://github.com/cyberbotics/webots/pull/6593))
2 changes: 1 addition & 1 deletion src/webots/nodes/WbSpeaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ void WbSpeaker::playSound(const char *file, double volume, double pitch, double
if (!mSoundSourcesMap.contains(key)) { // this sound was never played
QString path;
// check if the path is absolute
if (QDir::isAbsolutePath(filename))
if (QDir::isAbsolutePath(filename) && QFile::exists(filename))
path = filename;
// check if the path is relative to the controller
if (path.isEmpty() && QFile::exists(mControllerDir + filename))
Expand Down
6 changes: 3 additions & 3 deletions src/webots/sound/WbWaveFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ void WbWaveFile::loadConvertedFile(int side) {
}

if (riffChunkRead == false)
throw("Corrupted WAVE file: RIFF chunk not found");
throw(QObject::tr("Corrupted WAVE file: RIFF chunk not found"));

if (formatChunkRead == false)
throw("Corrupted WAVE file: format chunk not found");
throw(QObject::tr("Corrupted WAVE file: format chunk not found"));

if (dataChunkRead == false)
throw("Corrupted WAVE file: data chunk not found");
throw(QObject::tr("Corrupted WAVE file: data chunk not found"));

} catch (const QString &e) {
// clean up
Expand Down

0 comments on commit 9902e0b

Please sign in to comment.