From 213bc9aecef4f58e95e7d09d0c1e65cf30f4a1d9 Mon Sep 17 00:00:00 2001
From: Ivica Ico Bukvic <ico@monsoon.(none)>
Date: Thu, 18 Oct 2012 21:48:44 -0400
Subject: [PATCH] provided a more robust way of suspending dsp before closing
 the patch... needs testing to see if this fixes lingering sporadic crashes
 when quitting without closing the patch.

---
 src/g_canvas.c | 4 +++-
 src/s_inter.c  | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/g_canvas.c b/src/g_canvas.c
index 833ab7336..7a4b02814 100644
--- a/src/g_canvas.c
+++ b/src/g_canvas.c
@@ -1419,17 +1419,19 @@ static void canvas_stop_dsp(void)
     /* DSP can be suspended before, and resumed after, operations which
     might affect the DSP chain.  For example, we suspend before loading and
     resume afterward, so that DSP doesn't get resorted for every DSP object
-    int the patch. */
+    in the patch. */
 
 int canvas_suspend_dsp(void)
 {
     int rval = canvas_dspstate;
+	//fprintf(stderr,"canvas_suspend_dsp %d\n", rval);
     if (rval) canvas_stop_dsp();
     return (rval);
 }
 
 void canvas_resume_dsp(int oldstate)
 {
+	//fprintf(stderr,"canvas_resume_dsp %d\n", oldstate);
     if (oldstate) canvas_start_dsp();
 }
 
diff --git a/src/s_inter.c b/src/s_inter.c
index 913df89db..cdea5f169 100644
--- a/src/s_inter.c
+++ b/src/s_inter.c
@@ -1324,6 +1324,7 @@ void glob_quit(void *dummy)
 	//let's try to cleanly remove invisible template canvases
 	//if (garray_arraytemplatecanvas) canvas_free( (t_canvas *)garray_arraytemplatecanvas);
 	//if (garray_floattemplatecanvas) canvas_free( (t_canvas *)garray_floattemplatecanvas);
+	canvas_suspend_dsp();
 	glob_closeall(0, 1);
     sys_vgui("exit\n");
     if (!sys_nogui)
-- 
GitLab