SATGroup: fix misuse of BReferenceable object

LinearSpec is a BReferenceable, so it is not correct to allocate it as a
member of another object. Wrap it in a BReference to avoid the problem.

Fixes #11089.
This commit is contained in:
Adrien Destugues
2015-01-23 13:05:38 +01:00
parent a82d6bdd3e
commit 84ed7b4bb4
2 changed files with 26 additions and 15 deletions
+24 -13
View File
@@ -377,14 +377,18 @@ WindowArea::MoveToTopLayer(SATWindow* window)
void
WindowArea::_UninitConstraints()
{
LinearSpec* linearSpec = fGroup->GetLinearSpec();
if (fGroup != NULL) {
LinearSpec* linearSpec = fGroup->GetLinearSpec();
linearSpec->RemoveConstraint(fMinWidthConstraint, true);
linearSpec->RemoveConstraint(fMinHeightConstraint, true);
linearSpec->RemoveConstraint(fMaxWidthConstraint, true);
linearSpec->RemoveConstraint(fMaxHeightConstraint, true);
linearSpec->RemoveConstraint(fWidthConstraint, true);
linearSpec->RemoveConstraint(fHeightConstraint, true);
if (linearSpec != NULL) {
linearSpec->RemoveConstraint(fMinWidthConstraint, true);
linearSpec->RemoveConstraint(fMinHeightConstraint, true);
linearSpec->RemoveConstraint(fMaxWidthConstraint, true);
linearSpec->RemoveConstraint(fMaxHeightConstraint, true);
linearSpec->RemoveConstraint(fWidthConstraint, true);
linearSpec->RemoveConstraint(fHeightConstraint, true);
}
}
fMinWidthConstraint = NULL;
fMinHeightConstraint = NULL;
@@ -787,6 +791,7 @@ Tab::CompareFunction(const Tab* tab1, const Tab* tab2)
SATGroup::SATGroup()
:
fLinearSpec(new(std::nothrow) LinearSpec(), true),
fHorizontalTabsSorted(false),
fVerticalTabsSorted(false),
fActiveWindow(NULL)
@@ -797,6 +802,8 @@ SATGroup::SATGroup()
SATGroup::~SATGroup()
{
// Should be empty
if (fSATWindowList.CountItems() > 0)
debugger("Deleting a SATGroup which is not empty");
//while (fSATWindowList.CountItems() > 0)
// RemoveWindow(fSATWindowList.ItemAt(0));
}
@@ -1100,12 +1107,14 @@ SATGroup::ArchiveGroup(BMessage& archive)
BReference<Tab>
SATGroup::_AddHorizontalTab(float position)
{
Variable* variable = fLinearSpec.AddVariable();
if (!variable)
if (fLinearSpec == NULL)
return NULL;
Variable* variable = fLinearSpec->AddVariable();
if (variable == NULL)
return NULL;
Tab* tab = new (std::nothrow)Tab(this, variable, Tab::kHorizontal);
if (!tab)
if (tab == NULL)
return NULL;
BReference<Tab> tabRef(tab, true);
@@ -1121,12 +1130,14 @@ SATGroup::_AddHorizontalTab(float position)
BReference<Tab>
SATGroup::_AddVerticalTab(float position)
{
Variable* variable = fLinearSpec.AddVariable();
if (!variable)
if (fLinearSpec == NULL)
return NULL;
Variable* variable = fLinearSpec->AddVariable();
if (variable == NULL)
return NULL;
Tab* tab = new (std::nothrow)Tab(this, variable, Tab::kVertical);
if (!tab)
if (tab == NULL)
return NULL;
BReference<Tab> tabRef(tab, true);
+2 -2
View File
@@ -244,7 +244,7 @@ public:
SATGroup();
~SATGroup();
LinearSpec* GetLinearSpec() { return &fLinearSpec; }
LinearSpec* GetLinearSpec() { return fLinearSpec.Get(); }
/*! Create a new WindowArea from the crossing and add the window. */
bool AddWindow(SATWindow* window, Tab* left,
@@ -321,7 +321,7 @@ protected:
WindowAreaList fWindowAreaList;
SATWindowList fSATWindowList;
LinearSpec fLinearSpec;
BReference<LinearSpec> fLinearSpec;
private:
TabList fHorizontalTabs;