Merge "[apps] Ensure to reset pointers when their content have been deleted"

This commit is contained in:
Émilie Feral
2017-02-17 16:39:14 +01:00
committed by Gerrit
8 changed files with 19 additions and 3 deletions

View File

@@ -15,15 +15,19 @@ Calculation::Calculation() :
Calculation::~Calculation() {
if (m_inputLayout != nullptr) {
delete m_inputLayout;
m_inputLayout = nullptr;
}
if (m_input != nullptr) {
delete m_input;
m_input = nullptr;
}
if (m_output != nullptr) {
delete m_output;
m_output = nullptr;
}
if (m_outputLayout != nullptr) {
delete m_outputLayout;
m_outputLayout = nullptr;
}
}

View File

@@ -1,7 +1,7 @@
#include "values_controller.h"
#include "../app.h"
#include "../../constant.h"
#include "../../apps_container.h"
#include "../app.h"
#include <assert.h>
using namespace Poincare;

View File

@@ -17,6 +17,7 @@ ListParameterController::ListParameterController(Responder * parentResponder, Se
ListParameterController::~ListParameterController() {
if (m_typeLayout) {
delete m_typeLayout;
m_typeLayout = nullptr;
}
}
@@ -29,6 +30,7 @@ void ListParameterController::setSequence(Sequence * sequence) {
m_sequence = sequence;
if (m_typeLayout != nullptr) {
delete m_typeLayout;
m_typeLayout = nullptr;
}
if (m_sequence->type() == Sequence::Type::Explicite) {
m_typeLayout = new BaselineRelativeLayout(new StringLayout(m_sequence->name(), 1), new StringLayout("n", 1, KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript);

View File

@@ -21,6 +21,7 @@ SequenceTitleCell::~SequenceTitleCell() {
for (int i = 0; i < 3; i++) {
if (m_expressionLayouts[i]) {
delete m_expressionLayouts[i];
m_expressionLayouts[i] = nullptr;
}
}
}
@@ -28,8 +29,9 @@ SequenceTitleCell::~SequenceTitleCell() {
void SequenceTitleCell::setSequence(Sequence * sequence) {
SequenceCell::setSequence(sequence);
for (int i = 0; i < 3; i++) {
if (m_expressionLayouts[i]) {
if (m_expressionLayouts[i]!= nullptr) {
delete m_expressionLayouts[i];
m_expressionLayouts[i] = nullptr;
}
}
if (m_numberOfSubCells == 1) {

View File

@@ -21,6 +21,7 @@ TypeParameterController::~TypeParameterController() {
for (int i = 0; i < k_totalNumberOfCell; i++) {
if (m_expressionLayouts[i]) {
delete m_expressionLayouts[i];
m_expressionLayouts[i] = nullptr;
}
}
}
@@ -73,6 +74,7 @@ void TypeParameterController::willDisplayCellAtLocation(TableViewCell * cell, in
const char * subscripts[3] = {"n", "n+1", "n+2"};
if (m_expressionLayouts[j]) {
delete m_expressionLayouts[j];
m_expressionLayouts[j] = nullptr;
}
m_expressionLayouts[j] = new BaselineRelativeLayout(new StringLayout(nextName, 1), new StringLayout(subscripts[j], strlen(subscripts[j]), KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript);
TextExpressionMenuListCell * myCell = (TextExpressionMenuListCell *)cell;

View File

@@ -21,15 +21,19 @@ Sequence::~Sequence() {
((Function *)this)->Shared::Function::~Function();
if (m_firstInitialConditionLayout != nullptr) {
delete m_firstInitialConditionLayout;
m_firstInitialConditionLayout = nullptr;
}
if (m_secondInitialConditionLayout != nullptr) {
delete m_secondInitialConditionLayout;
m_secondInitialConditionLayout = nullptr;
}
if (m_firstInitialConditionExpression != nullptr) {
delete m_firstInitialConditionExpression;
m_firstInitialConditionExpression = nullptr;
}
if (m_secondInitialConditionExpression != nullptr) {
delete m_secondInitialConditionExpression;
m_secondInitialConditionExpression = nullptr;
}
}

View File

@@ -1,9 +1,9 @@
#include "curve_view.h"
#include "../constant.h"
#include <assert.h>
#include <string.h>
#include <math.h>
#include <float.h>
#include <string.h>
using namespace Poincare;

View File

@@ -36,9 +36,11 @@ void Function::setColor(KDColor color) {
Function::~Function() {
if (m_layout != nullptr) {
delete m_layout;
m_layout = nullptr;
}
if (m_expression != nullptr) {
delete m_expression;
m_expression = nullptr;
}
}