Fix SoundBuffer copy & move methods

master
Dorian Wouters 2018-08-18 22:15:38 +02:00
parent f8035472a7
commit 8f343ee214
No known key found for this signature in database
GPG Key ID: 6E9DA8063322434B
2 changed files with 9 additions and 1 deletions

View File

@ -52,12 +52,18 @@ const char* alGetErrorString(ALenum error) {
SoundBuffer::SoundBuffer() : m_id(0) {
}
SoundBuffer::SoundBuffer(SoundBuffer &&b) {
SoundBuffer::SoundBuffer(SoundBuffer &&b) :
m_id(b.m_id) {
b.m_id = 0;
}
SoundBuffer& SoundBuffer::operator=(SoundBuffer &&b) {
if (m_id != 0) {
alDeleteBuffers(1, &m_id);
}
m_id = b.m_id;
b.m_id = 0;
return *this;
}
SoundBuffer::~SoundBuffer() {

View File

@ -21,6 +21,8 @@ public:
SoundBuffer(const SoundBuffer&) = delete;
SoundBuffer(SoundBuffer&&);
SoundBuffer& operator=(const SoundBuffer&) = delete;
SoundBuffer& operator=(SoundBuffer&&);
~SoundBuffer();