mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 22:22:54 +02:00
Protect against null pointer usage in sound scripting wrapper
This commit is contained in:
parent
72fc686ec1
commit
5adc4c2290
2 changed files with 9 additions and 6 deletions
|
@ -43,8 +43,11 @@ void soundSharedPointerFromScriptValue(const QScriptValue& object, SharedSoundPo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundScriptingInterface::SoundScriptingInterface(SharedSoundPointer sound) : _sound(sound) {
|
SoundScriptingInterface::SoundScriptingInterface(const SharedSoundPointer& sound) : _sound(sound) {
|
||||||
QObject::connect(sound.data(), &Sound::ready, this, &SoundScriptingInterface::ready);
|
// During shutdown we can sometimes get an empty sound pointer back
|
||||||
|
if (_sound) {
|
||||||
|
QObject::connect(_sound.data(), &Sound::ready, this, &SoundScriptingInterface::ready);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Sound::Sound(const QUrl& url, bool isStereo, bool isAmbisonic) :
|
Sound::Sound(const QUrl& url, bool isStereo, bool isAmbisonic) :
|
||||||
|
|
|
@ -105,11 +105,11 @@ class SoundScriptingInterface : public QObject {
|
||||||
Q_PROPERTY(float duration READ getDuration)
|
Q_PROPERTY(float duration READ getDuration)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SoundScriptingInterface(SharedSoundPointer sound);
|
SoundScriptingInterface(const SharedSoundPointer& sound);
|
||||||
SharedSoundPointer getSound() { return _sound; }
|
const SharedSoundPointer& getSound() { return _sound; }
|
||||||
|
|
||||||
bool isReady() const { return _sound->isReady(); }
|
bool isReady() const { return _sound ? _sound->isReady() : false; }
|
||||||
float getDuration() { return _sound->getDuration(); }
|
float getDuration() { return _sound ? _sound->getDuration() : 0.0f; }
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Triggered when the sound has been downloaded and is ready to be played.
|
* Triggered when the sound has been downloaded and is ready to be played.
|
||||||
|
|
Loading…
Reference in a new issue