Skip to content

Commit

Permalink
Make it possible to have a Variable not belonging to any LinearSpec.
Browse files Browse the repository at this point in the history
  • Loading branch information
yourpalal committed May 2, 2012
1 parent bc7956c commit 0a408e4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/libs/linprog/LinearSpec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/libs/linprog/Variable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ Variable::RemoveReference()
*/
Variable::~Variable()
{
fLS->RemoveVariable(this, false);
if (fLS)
fLS->RemoveVariable(this, false);
}

0 comments on commit 0a408e4

Please sign in to comment.