Skip to content

Commit 9902e0b

Browse files
6592 invalid sound path results in crash (cyberbotics#6593)
* Fixed expected QObject on throw * Ensure absolute paths exist * Updated changelog --------- Co-authored-by: Olivier Michel <Olivier.Michel@cyberbotics.com>
1 parent 0c44a3d commit 9902e0b

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

docs/reference/changelog-r2024.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ Released on December **th, 2023.
1616
- Fixed handling of device objects with the same name in the controller API ([#6579](https://github.com/cyberbotics/webots/pull/6579)).
1717
- Fixed crashes (with some graphics cards) caused by references to unused GLSL uniforms ([#6587](https://github.com/cyberbotics/webots/pull/6587)).
1818
- 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)).
19+
- Fixed invalid absolute sound file path resulted in crash ([#6593](https://github.com/cyberbotics/webots/pull/6593))

src/webots/nodes/WbSpeaker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ void WbSpeaker::playSound(const char *file, double volume, double pitch, double
205205
if (!mSoundSourcesMap.contains(key)) { // this sound was never played
206206
QString path;
207207
// check if the path is absolute
208-
if (QDir::isAbsolutePath(filename))
208+
if (QDir::isAbsolutePath(filename) && QFile::exists(filename))
209209
path = filename;
210210
// check if the path is relative to the controller
211211
if (path.isEmpty() && QFile::exists(mControllerDir + filename))

src/webots/sound/WbWaveFile.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,13 @@ void WbWaveFile::loadConvertedFile(int side) {
138138
}
139139

140140
if (riffChunkRead == false)
141-
throw("Corrupted WAVE file: RIFF chunk not found");
141+
throw(QObject::tr("Corrupted WAVE file: RIFF chunk not found"));
142142

143143
if (formatChunkRead == false)
144-
throw("Corrupted WAVE file: format chunk not found");
144+
throw(QObject::tr("Corrupted WAVE file: format chunk not found"));
145145

146146
if (dataChunkRead == false)
147-
throw("Corrupted WAVE file: data chunk not found");
147+
throw(QObject::tr("Corrupted WAVE file: data chunk not found"));
148148

149149
} catch (const QString &e) {
150150
// clean up

0 commit comments

Comments
 (0)