Merge pull request #2747 from Fyrult/memoryLeaks

fix memory leaks
This commit is contained in:
Nicolas Froment 2016-07-19 09:44:16 +02:00 committed by GitHub
commit 8646f2f8a3
7 changed files with 32 additions and 21 deletions

View file

@ -107,14 +107,11 @@ void Fluid::init(float sampleRate)
Fluid::~Fluid()
{
_state = FLUID_SYNTH_STOPPED;
foreach(Voice* v, activeVoices)
delete v;
foreach(Voice* v, freeVoices)
delete v;
foreach(SFont* sf, sfonts)
delete sf;
foreach(Channel* c, channel)
delete c;
qDeleteAll(activeVoices);
qDeleteAll(freeVoices);
qDeleteAll(sfonts);
qDeleteAll(channel);
qDeleteAll(patches);
}
//---------------------------------------------------------

View file

@ -2644,8 +2644,10 @@ static QPixmap createThumbnail(const QString& name)
{
MasterScore* score = new MasterScore;
Score::FileError error = readScore(score, name, true);
if (error != Score::FileError::FILE_NO_ERROR)
if (error != Score::FileError::FILE_NO_ERROR) {
delete score;
return QPixmap();
}
score->doLayout();
QImage pm = score->createThumbnail();
delete score;

View file

@ -2286,15 +2286,18 @@ void loadTranslation(QString filename, QString localeName)
QFile::remove(userlp + ".qm");
}
if (MScore::debugMode) qDebug("load translator <%s>", qPrintable(lp));
if (MScore::debugMode)
qDebug("load translator <%s>", qPrintable(lp));
bool success = translator->load(lp);
if (!success && MScore::debugMode) {
qDebug("load translator <%s> failed", qPrintable(lp));
}
if(success) {
if (success) {
qApp->installTranslator(translator);
translatorList.append(translator);
}
else {
if (MScore::debugMode)
qDebug("load translator <%s> failed", qPrintable(lp));
delete translator;
}
}
//---------------------------------------------------------

View file

@ -8835,9 +8835,9 @@ QIcon MgStyle::getCachedIcon(QString key) const
if (pixmap)
return QIcon(*pixmap);
else {
QIcon* icon = new QIcon(new MIconEngine);
icon->addFile(key);
QPixmapCache::insert(key, icon->pixmap(48));
return *icon;
QIcon icon = QIcon(new MIconEngine);
icon.addFile(key);
QPixmapCache::insert(key, icon.pixmap(48));
return icon;
}
}

View file

@ -86,8 +86,11 @@ MasterSynthesizer::~MasterSynthesizer()
{
for (Synthesizer* s : _synthesizer)
delete s;
for (int i = 0; i < MAX_EFFECTS; ++i)
delete _effect[i];
for (int i = 0; i < MAX_EFFECTS; ++i) {
for (Effect* e : _effectList[i])
delete e;
// delete _effect[i]; // _effect takes from _effectList
}
}
//---------------------------------------------------------

View file

@ -74,6 +74,8 @@ Zerberus::~Zerberus()
globalInstruments.erase(it);
}
}
for (Channel* c : _channel)
delete c;
}
//---------------------------------------------------------

View file

@ -20,8 +20,8 @@
#include "synthesizer/synthesizer.h"
#include "synthesizer/event.h"
#include "voice.h"
class Voice;
class Channel;
class ZInstrument;
enum class Trigger : char;
@ -44,6 +44,10 @@ class VoiceFifo {
VoiceFifo() {
n = 0;
}
~VoiceFifo() {
for (Voice* v : buffer)
delete v;
}
void push(Voice* v) {
buffer[writeIdx++] = v;
writeIdx %= MAX_VOICES;