Use BReferenceable properties of LinearSpec in BALMLayout.

This saves us from a potential use-afte-free bug.
This commit is contained in:
Alex Wilson 2012-01-18 17:10:10 +13:00
parent 7c3800078e
commit f9cabdd009
2 changed files with 3 additions and 3 deletions

View File

@ -170,7 +170,6 @@ private:
bool _TrySolve();
LinearProgramming::LinearSpec* fSolver;
LinearProgramming::LinearSpec fOwnSolver;
BReference<XTab> fLeft;
BReference<XTab> fRight;

View File

@ -13,7 +13,6 @@
#include <ControlLook.h>
#include "ALMGroup.h"
#include "RowColumnManager.h"
#include "ViewLayoutItem.h"
@ -61,7 +60,8 @@ BALMLayout::BALMLayout(float hSpacing, float vSpacing, BALMLayout* friendLayout)
fVSpacing(BControlLook::ComposeSpacing(vSpacing)),
fBadLayoutPolicy(new DefaultPolicy())
{
fSolver = friendLayout ? friendLayout->Solver() : &fOwnSolver;
fSolver = friendLayout ? friendLayout->Solver() : new LinearSpec();
fSolver->AcquireReference();
fRowColumnManager = new RowColumnManager(fSolver);
fLeft = AddXTab();
@ -86,6 +86,7 @@ BALMLayout::~BALMLayout()
{
delete fRowColumnManager;
delete fBadLayoutPolicy;
fSolver->ReleaseReference();
}