From fbc3068ab1ef2f01e5d3042d207795a8f08e5edc Mon Sep 17 00:00:00 2001
From: Florian Atteneder <florian.atteneder@uni-jena.de>
Date: Sat, 1 Apr 2023 20:59:31 +0200
Subject: [PATCH] fix wrong callback invokation when finishing

---
 src/main.jl | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/main.jl b/src/main.jl
index de914d01..aeb03e19 100644
--- a/src/main.jl
+++ b/src/main.jl
@@ -56,18 +56,19 @@ function main(parfile)
   finally
 
     # finish timer and progress bar
-    idx = findfirst(cb -> cb isa TimerOutputCallback, reverse(env.callbacks.callbacks))
+    idx = findlast(cb -> cb isa TimerOutputCallback, env.callbacks.callbacks)
     if !isnothing(idx)
       timercb = env.callbacks.callbacks[idx]
       timercb([], 0.0, 0, force=true)
     end
-    idx = findfirst(cb -> cb isa ProgressCallback, reverse(env.callbacks.callbacks))
-    if !isnothing(idx)
-      progresscb = env.callbacks.callbacks[idx]
-      progresscb([], 0.0, 0, force=true)
-    else
-      display(dg1d.TO)
-    end
+    # Can't force atm, because ProgressCallback uses an internal CallbackTiming...
+    # forwarded through the callback, henc
+    # idx = findlast(cb -> cb isa ProgressCallback, env.callbacks.callbacks)
+    # if !isnothing(idx)
+    #   progresscb = env.callbacks.callbacks[idx]
+    #   progresscb([], 0.0, 0, force=true)
+    # end
+    display(dg1d.TO)
 
   end
 
-- 
GitLab