advance compilation to include plugin_ui.cc
[ardour.git] / libs / cassowary / ClBug2.cc
1 /* $Id$
2
3 From: "Anthony Beurive'" <beurive@labri.u-bordeaux.fr> 
4 Subject: cassowary 
5 To: gjb@cs.washington.edu 
6 Date: Tue, 9 Mar 1999 12:42:24 +0100 (CET) 
7
8 I believe there's a bug in cassowary.  It seems to be related to the 
9 previous one I encountered a while ago, concerning the removal of 
10 constraints. 
11  
12 The three following examples may help you to track the bug, I hope. 
13  
14 -------------------------------------------------------------------------------- 
15 #include "Cl.h" 
16  
17 void main() 
18
19   ClSimplexSolver *solver = new ClSimplexSolver(); 
20   ClVariable *var = new ClVariable(); 
21   ClStayConstraint *stcn = new ClStayConstraint(*var,ClsWeak(),1.0); 
22  
23   solver->AddConstraint(*stcn); 
24   cout << *solver; 
25   solver->RemoveConstraint(*stcn); 
26   cout << *solver; 
27
28 -------------------------------------------------------------------------------- 
29 This works fine. 
30  
31  
32 Now, the factor of the stay constraint is changed. 
33 -------------------------------------------------------------------------------- 
34 #include "Cl.h" 
35  
36 void main() 
37
38   ClSimplexSolver *solver = new ClSimplexSolver(); 
39   ClVariable *var = new ClVariable(); 
40   ClStayConstraint *stcn = new ClStayConstraint(*var,ClsWeak(),2.0); 
41  
42   solver->AddConstraint(*stcn); 
43   cout << *solver; 
44   solver->RemoveConstraint(*stcn); 
45   cout << *solver; 
46
47 -------------------------------------------------------------------------------- 
48 The result is: 
49 test2: ClSimplexSolver.cc:1199: void ClSimplexSolver::Optimize(class ClVariable): Assertion \
50 `pzRow != __null' failed. 
51 Aborted 
52  
53  
54 Now, the solver is created after the variable. 
55 -------------------------------------------------------------------------------- 
56 #include "Cl.h" 
57  
58 void main() 
59
60   ClVariable *var = new ClVariable(); 
61   ClSimplexSolver *solver = new ClSimplexSolver(); 
62   ClStayConstraint *stcn = new ClStayConstraint(*var,ClsWeak(),2.0); 
63  
64   solver->AddConstraint(*stcn); 
65   cout << *solver; 
66   solver->RemoveConstraint(*stcn); 
67   cout << *solver; 
68
69 -------------------------------------------------------------------------------- 
70 This works again. 
71  
72  
73 Can you reproduce the same results?  Maybe the cause is my c++ 
74 compiler (egcs-2.90.29 980515 (egcs-1.0.3 release)).  I don't know. 
75
76 */
77
78 #include <cassowary/Cl.h>
79
80 void foo1() 
81
82   ClSimplexSolver *solver = new ClSimplexSolver(); 
83   ClVariable *var = new ClVariable(); 
84   ClStayConstraint *stcn = new ClStayConstraint(*var,ClsWeak(),1.0); 
85  
86   solver->AddConstraint(*stcn); 
87   cout << *solver; 
88   solver->RemoveConstraint(*stcn); 
89   cout << *solver; 
90
91
92
93 void foo2() 
94
95   ClSimplexSolver *solver = new ClSimplexSolver(); 
96   ClVariable *var = new ClVariable(); 
97   ClStayConstraint *stcn = new ClStayConstraint(*var,ClsWeak(),2.0); 
98  
99   solver->AddConstraint(*stcn); 
100   cout << *solver; 
101   solver->RemoveConstraint(*stcn); 
102   cout << *solver; 
103
104
105
106 void foo3() 
107
108   ClVariable *var = new ClVariable(); 
109   ClSimplexSolver *solver = new ClSimplexSolver(); 
110   ClStayConstraint *stcn = new ClStayConstraint(*var,ClsWeak(),2.0); 
111  
112   solver->AddConstraint(*stcn); 
113   cout << *solver; 
114   solver->RemoveConstraint(*stcn); 
115   cout << *solver; 
116
117
118
119 int main()
120 {
121   cerr << "Test1: " << endl;
122   foo1();
123
124   cerr << "\nTest2: " << endl;
125   foo2();
126
127   cerr << "\nTest3: " << endl;
128   foo3();
129
130 }