[apps][escher] Do not forget to delete dynamic objects when reassigning

then or destructing them

Change-Id: If2b4de460163bf187152389e419d87329b83fc39
This commit is contained in:
Émilie Feral
2017-03-03 11:27:59 +01:00
committed by Romain Goyet
parent 276504e978
commit 7406e0d775
5 changed files with 31 additions and 0 deletions

View File

@@ -13,6 +13,15 @@ SequenceToolbox::SequenceToolbox() :
{
}
SequenceToolbox::~SequenceToolbox() {
for (int i = 0; i < k_maxNumberOfDisplayedRows; i++) {
if (m_addedCellLayout[i]) {
delete m_addedCellLayout[i];
m_addedCellLayout[i] = nullptr;
}
}
}
bool SequenceToolbox::handleEvent(Ion::Events::Event event) {
if (event == Ion::Events::OK && stackDepth() == 0) {
int selectedRow = m_selectableTableView.selectedRow();
@@ -65,6 +74,12 @@ int SequenceToolbox::typeAtLocation(int i, int j) {
}
void SequenceToolbox::setExtraCells(const char * sequenceName, int recurrenceDepth) {
for (int i = 0; i < k_maxNumberOfDisplayedRows; i++) {
if (m_addedCellLayout[i]) {
delete m_addedCellLayout[i];
m_addedCellLayout[i] = nullptr;
}
}
m_numberOfAddedCells = recurrenceDepth;
for (int j = 0; j < recurrenceDepth; j++) {
m_addedCellLayout[j] = new BaselineRelativeLayout(new StringLayout(sequenceName, 1, KDText::FontSize::Large), new StringLayout((char *)(j == 0? "n" : "n+1"), strlen((char *)(j == 0? "n" : "n+1")), KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript);