From 20cc993ab504286d6c59bcbe273a040e61eafe7f Mon Sep 17 00:00:00 2001 From: Alex Wilson Date: Wed, 18 Jan 2012 09:20:07 +1300 Subject: [PATCH] Remove BALM::Area::fConstraints field, which is not needed. It's easier to just delete all the constraints in the dtor, the ones that wouldn't have been in fConstraints are NULL at this point anyway. --- headers/libs/alm/Area.h | 2 -- src/libs/alm/Area.cpp | 30 +++++++++--------------------- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/headers/libs/alm/Area.h b/headers/libs/alm/Area.h index c59a5ddde0..66be69b810 100644 --- a/headers/libs/alm/Area.h +++ b/headers/libs/alm/Area.h @@ -6,7 +6,6 @@ #define AREA_H -#include #include #include #include @@ -137,7 +136,6 @@ private: double fContentAspectRatio; RowColumnManager* fRowColumnManager; - BObjectList fConstraints; LinearProgramming::Constraint* fMinContentWidth; LinearProgramming::Constraint* fMaxContentWidth; LinearProgramming::Constraint* fMinContentHeight; diff --git a/src/libs/alm/Area.cpp b/src/libs/alm/Area.cpp index c3de69bad6..0f25e3a82a 100644 --- a/src/libs/alm/Area.cpp +++ b/src/libs/alm/Area.cpp @@ -227,7 +227,6 @@ Area::SetContentAspectRatio(double ratio) } else if (fContentAspectRatioC == NULL) { fContentAspectRatioC = fLS->AddConstraint(-1.0, fLeft, 1.0, fRight, ratio, fTop, -ratio, fBottom, kEQ, 0.0); - fConstraints.AddItem(fContentAspectRatioC); } else { fContentAspectRatioC->SetLeftSide(-1.0, fLeft, 1.0, fRight, ratio, fTop, -ratio, fBottom); @@ -469,8 +468,11 @@ Area::Frame() const */ Area::~Area() { - for (int32 i = 0; i < fConstraints.CountItems(); i++) - delete fConstraints.ItemAt(i); + delete fMinContentWidth; + delete fMaxContentWidth; + delete fMinContentHeight; + delete fMaxContentHeight; + delete fContentAspectRatioC; } @@ -490,27 +492,21 @@ new_area_id() Area::Area(BLayoutItem* item) : fLayoutItem(item), - fLS(NULL), fLeft(NULL), fRight(NULL), fTop(NULL), fBottom(NULL), - fRow(NULL), fColumn(NULL), - fShrinkPenalties(5, 5), fGrowPenalties(5, 5), - fContentAspectRatio(-1), fRowColumnManager(NULL), - fMinContentWidth(NULL), fMaxContentWidth(NULL), fMinContentHeight(NULL), fMaxContentHeight(NULL), - fContentAspectRatioC(NULL) { fID = new_area_id(); @@ -551,16 +547,14 @@ Area::_Init(LinearSpec* ls, XTab* left, YTab* top, XTab* right, YTab* bottom, // really above the bottom y-tab fMinContentWidth = ls->AddConstraint(-1.0, fLeft, 1.0, fRight, kGE, 0); fMinContentHeight = ls->AddConstraint(-1.0, fTop, 1.0, fBottom, kGE, 0); - - fConstraints.AddItem(fMinContentWidth); - fConstraints.AddItem(fMinContentHeight); } void Area::_Init(LinearSpec* ls, Row* row, Column* column, RowColumnManager* manager) { - _Init(ls, column->Left(), row->Top(), column->Right(), row->Bottom(), manager); + _Init(ls, column->Left(), row->Top(), column->Right(), + row->Bottom(), manager); fRow = row; fColumn = column; @@ -615,12 +609,9 @@ Area::_UpdateMaxSizeConstraint(BSize max) if (fMaxContentHeight == NULL) { fMaxContentHeight = fLS->AddConstraint(-1.0, fTop, 1.0, fBottom, kLE, max.Height()); - fConstraints.AddItem(fMaxContentHeight); } else fMaxContentHeight->SetRightSide(max.Height()); - } - else { - fConstraints.RemoveItem(fMaxContentHeight); + } else { delete fMaxContentHeight; fMaxContentHeight = NULL; } @@ -629,12 +620,9 @@ Area::_UpdateMaxSizeConstraint(BSize max) if (fMaxContentWidth == NULL) { fMaxContentWidth = fLS->AddConstraint(-1.0, fLeft, 1.0, fRight, kLE, max.Width()); - fConstraints.AddItem(fMaxContentWidth); } else fMaxContentWidth->SetRightSide(max.Width()); - } - else { - fConstraints.RemoveItem(fMaxContentWidth); + } else { delete fMaxContentWidth; fMaxContentWidth = NULL; }