Make it possible to have a Variable not belonging to any LinearSpec.

This commit is contained in:
Alex Wilson 2012-02-01 09:52:55 +13:00
parent bc7956c7cf
commit 0a408e4992
2 changed files with 5 additions and 1 deletions

View File

@ -93,6 +93,9 @@ LinearSpec::AddVariable(Variable* variable)
if (!fVariables.AddItem(variable))
return false;
if (variable->fLS == NULL)
variable->fLS = this;
if (!fSolver->VariableAdded(variable)) {
fVariables.RemoveItem(variable);
return false;

View File

@ -325,6 +325,7 @@ Variable::RemoveReference()
*/
Variable::~Variable()
{
fLS->RemoveVariable(this, false);
if (fLS)
fLS->RemoveVariable(this, false);
}