mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-26 17:20:53 +01:00
[apps][escher] Do not forget to delete dynamic objects when reassigning
then or destructing them Change-Id: If2b4de460163bf187152389e419d87329b83fc39
This commit is contained in:
committed by
Romain Goyet
parent
276504e978
commit
7406e0d775
@@ -19,6 +19,15 @@ StoreController::StoreController(Responder * parentResponder, Store * store, But
|
||||
m_titleLayout[1] = new BaselineRelativeLayout(new StringLayout("Y", 1, KDText::FontSize::Small), new StringLayout("i", 1, KDText::FontSize::Small), BaselineRelativeLayout::Type::Subscript);
|
||||
}
|
||||
|
||||
StoreController::~StoreController() {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
if (m_titleLayout[i]) {
|
||||
delete m_titleLayout[i];
|
||||
m_titleLayout[i] = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StoreController::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) {
|
||||
::StoreController::willDisplayCellAtLocation(cell, i, j);
|
||||
if (cellAtLocationIsEditable(i, j)) {
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace Regression {
|
||||
class StoreController : public Shared::StoreController {
|
||||
public:
|
||||
StoreController(Responder * parentResponder, Store * store, ButtonRowController * header);
|
||||
~StoreController();
|
||||
void willDisplayCellAtLocation(HighlightCell * cell, int i, int j) override;
|
||||
private:
|
||||
HighlightCell * titleCells(int index) override;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace Sequence {
|
||||
class SequenceToolbox : public MathToolbox {
|
||||
public:
|
||||
SequenceToolbox();
|
||||
~SequenceToolbox();
|
||||
bool handleEvent(Ion::Events::Event event) override;
|
||||
int numberOfRows() override;
|
||||
HighlightCell * reusableCell(int index, int type) override;
|
||||
|
||||
@@ -22,6 +22,11 @@ public:
|
||||
void setAlignment(float horizontalAlignment, float verticalAlignment);
|
||||
KDSize minimalSizeForOptimalDisplay() override;
|
||||
private:
|
||||
/* Warning: we do not need to delete the previous expression layout when
|
||||
* deleting object or setting a new expression layout. Indeed, the expression
|
||||
* layout is always possessed by a controller which only gives a pointer to
|
||||
* the expression view (without cloning it). The named controller is then
|
||||
* responsible for freeing the expression layout when required. */
|
||||
Poincare::ExpressionLayout * m_expressionLayout;
|
||||
float m_horizontalAlignment;
|
||||
float m_verticalAlignment;
|
||||
|
||||
Reference in New Issue
Block a user