summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/drumkitloader.cc2
-rw-r--r--src/instrument.cc6
-rw-r--r--src/instrument.h2
-rw-r--r--src/instrumentparser.cc8
-rw-r--r--src/instrumentparser.h1
5 files changed, 7 insertions, 12 deletions
diff --git a/src/drumkitloader.cc b/src/drumkitloader.cc
index f2ef61a..7eab562 100644
--- a/src/drumkitloader.cc
+++ b/src/drumkitloader.cc
@@ -143,7 +143,7 @@ void DrumKitLoader::loadKit(DrumKit *kit)
{
for(auto& audiofile: instr_ptr->audiofiles)
{
- load_queue.push_back(audiofile);
+ load_queue.push_back(audiofile.get());
}
}
diff --git a/src/instrument.cc b/src/instrument.cc
index 9a4c0b7..8c78f40 100644
--- a/src/instrument.cc
+++ b/src/instrument.cc
@@ -47,12 +47,6 @@ Instrument::~Instrument()
magic = nullptr;
DEBUG(instrument, "delete %p\n", this);
- std::vector<AudioFile*>::iterator i = audiofiles.begin();
- while(i != audiofiles.end())
- {
- delete *i;
- i++;
- }
}
bool Instrument::isValid() const
diff --git a/src/instrument.h b/src/instrument.h
index ee67b3f..e61d446 100644
--- a/src/instrument.h
+++ b/src/instrument.h
@@ -56,7 +56,7 @@ public:
// std::map<std::string, std::string> channelmap;
- std::vector<AudioFile*> audiofiles;
+ std::vector<std::unique_ptr<AudioFile>> audiofiles;
bool isValid() const;
diff --git a/src/instrumentparser.cc b/src/instrumentparser.cc
index 1e42cc3..b42accd 100644
--- a/src/instrumentparser.cc
+++ b/src/instrumentparser.cc
@@ -31,6 +31,7 @@
#include <hugin.hpp>
+#include "cpp11fix.h"
#include "path.h"
#include "nolocale.h"
@@ -141,18 +142,17 @@ void InstrumentParser::startTag(const std::string& name, const attr_t& attr)
filechannel = filechannel - 1; // 1-based in file but zero-based internally.
- AudioFile *audio_file =
- new AudioFile(path + "/" + attr.at("file"), filechannel);
+ auto audio_file = std::make_unique<AudioFile>(path + "/" + attr.at("file"), filechannel);
// TODO: This is not deleted anywhere...
InstrumentChannel *instrument_channel =
new InstrumentChannel(attr.at("channel"));
channellist.push_back(instrument_channel);
- sample->addAudioFile(instrument_channel, audio_file);
+ sample->addAudioFile(instrument_channel, audio_file.get());
// Transfer audio_file ownership to the instrument.
- instrument.audiofiles.push_back(audio_file);
+ instrument.audiofiles.push_back(std::move(audio_file));
}
if(name == "velocities")
diff --git a/src/instrumentparser.h b/src/instrumentparser.h
index 6cbaf8a..793bfb6 100644
--- a/src/instrumentparser.h
+++ b/src/instrumentparser.h
@@ -29,6 +29,7 @@
#include "saxparser.h"
#include "instrument.h"
+#include <memory>
#include <vector>
class InstrumentParser