From 52b37cac974eb150d49eee1f0b5ba3654f6d7716 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gl=C3=B6ckner?= Date: Mon, 9 May 2016 11:09:06 +0200 Subject: Instrument Vector using UniquePtr --- src/drumkitparser.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/drumkitparser.cc') diff --git a/src/drumkitparser.cc b/src/drumkitparser.cc index 073d240..cd1c32d 100644 --- a/src/drumkitparser.cc +++ b/src/drumkitparser.cc @@ -30,6 +30,7 @@ #include #include +#include "cpp11fix.h" #include "instrumentparser.h" #include "path.h" #include "drumgizmo.h" @@ -184,14 +185,14 @@ void DrumKitParser::endTag(const std::string& name) { if(name == "instrument") { - Instrument* instrument = new Instrument(settings, rand); - instrument->setGroup(instr_group); - - InstrumentParser parser(*instrument); + auto ptr = std::make_unique(settings, rand); + ptr->setGroup(instr_group); + + InstrumentParser parser(*ptr); parser.parseFile(path + "/" + instr_file); // Transfer ownership to the DrumKit object. - kit.instruments.push_back(instrument); + kit.instruments.push_back(std::move(ptr)); // Assign kit channel numbers to instruments channels. std::vector::iterator ic = parser.channellist.begin(); @@ -216,7 +217,7 @@ void DrumKitParser::endTag(const std::string& name) if(c->num == NO_CHANNEL) { ERR(kitparser, "Missing channel '%s' in instrument '%s'\n", - c->name.c_str(), instrument->getName().c_str()); + c->name.c_str(), ptr->getName().c_str()); } else { -- cgit v1.2.3