Skip to content

Commit

Permalink
Fixed nested user-propagator callbacks in .NET (#6307)
Browse files Browse the repository at this point in the history
* Fixed nested user-propagator callbacks in .NET

* Typo
  • Loading branch information
CEisenhofer committed Aug 29, 2022
1 parent e2f4fc2 commit a0ca5d7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/api/dotnet/UserPropagator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class UserPropagator
Solver solver;
Context ctx;
Z3_solver_callback callback = IntPtr.Zero;
int callbackNesting = 0;
FixedEh fixed_eh;
Action final_eh;
EqEh eq_eh;
Expand All @@ -91,6 +92,7 @@ public class UserPropagator

void Callback(Action fn, Z3_solver_callback cb)
{
this.callbackNesting++;
this.callback = cb;
try
{
Expand All @@ -102,7 +104,9 @@ void Callback(Action fn, Z3_solver_callback cb)
}
finally
{
this.callback = IntPtr.Zero;
callbackNesting--;
if (callbackNesting == 0) // callbacks can be nested (e.g., internalizing new element in "created")
this.callback = IntPtr.Zero;
}
}

Expand Down

0 comments on commit a0ca5d7

Please sign in to comment.