Fixed memory leak in random_matrix and rainbow_matrix.

This commit is contained in:
Fabian Schlenz 2019-10-04 12:08:01 +02:00
parent af1314632e
commit 2b50691067

View File

@ -144,13 +144,19 @@ MatrixEffect::MatrixEffect() {
}
RandomMatrixEffect::RandomMatrixEffect() {
_columns = new MatrixEffectColumn* [window->width];
for (int i=0; i<window->width; i++) _columns[i] = new RandomMatrixEffectColumn(window, random8(4), true);
// No need to initialize _columns, because that will have been done by ctor of MatrixEffect.
for (int i=0; i<window->width; i++) {
delete _columns[i];
_columns[i] = new RandomMatrixEffectColumn(window, random8(4), true);
}
}
RainbowMatrixEffect::RainbowMatrixEffect() {
_columns = new MatrixEffectColumn* [window->width];
for (int i=0; i<window->width; i++) _columns[i] = new RainbowMatrixEffectColumn(window, MatrixEffectColumn::DIR_SOUTH);
// No need to initialize _columns, because that will have been done by ctor of MatrixEffect.
for (int i=0; i<window->width; i++) {
delete columns[i];
_columns[i] = new RainbowMatrixEffectColumn(window, MatrixEffectColumn::DIR_SOUTH);
}
}
MatrixEffect::~MatrixEffect() {