From c44eeec0629fcd4232b4b82b11ea36f58e9e4481 Mon Sep 17 00:00:00 2001
From: Ivica Ico Bukvic <ico@vt.edu>
Date: Tue, 31 Jul 2012 13:10:29 -0400
Subject: [PATCH] added dsp suspend when creating presets and a few more minor
 bug fixes

---
 src/x_preset.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/x_preset.c b/src/x_preset.c
index cb585501f..50f9511ff 100644
--- a/src/x_preset.c
+++ b/src/x_preset.c
@@ -359,7 +359,7 @@ static void preset_node_update_my_glist_location(t_preset_node *x)
 // nodes that have not been paired yet. 
 void preset_node_seek_hub(t_preset_node *x)
 {
-	if(PH_DEBUG) fprintf(stderr,"preset_node_seek_hub\n");
+	if(PH_DEBUG) fprintf(stderr,"preset_node_seek_hub %lx\n", (t_int)x->pn_hub);
 	t_canvas *y = x->pn_canvas;
 	t_preset_hub *h;
 
@@ -762,6 +762,8 @@ void preset_hub_store(t_preset_hub *h, t_float f)
 	np1 = NULL;
 	np2 = NULL;
 
+	int dspstate = canvas_suspend_dsp();
+
 	if (f>=0) {
 		//check if there are any existing nodes
 		if (h->ph_data) {
@@ -787,7 +789,7 @@ void preset_hub_store(t_preset_hub *h, t_float f)
 						}
 					}
 
-					if (!overwrite && np2->np_val.l_n > 0) {
+					if (!overwrite && hd1->phd_node->pn_val.l_n > 0) {
 						// we need to create a new preset (this is also true if hd1->phd_npreset is NULL)
 						changed = 1;
 						if(PH_DEBUG) fprintf(stderr,"	creating new preset\n");
@@ -798,7 +800,7 @@ void preset_hub_store(t_preset_hub *h, t_float f)
 						np2->np_preset = (int)f;
 					}
 
-					if (np2->np_val.l_n > 0) {
+					if (hd1->phd_node->pn_val.l_n > 0) {
 						changed = 1;
 						alist_clear(&np2->np_val);
 						if(PH_DEBUG) fprintf(stderr,"	node data len = %d, old hub data len = %d\n", hd1->phd_node->pn_val.l_n, np2->np_val.l_n);
@@ -814,6 +816,8 @@ void preset_hub_store(t_preset_hub *h, t_float f)
 				hd1 = hd1->phd_next;
 			}
 		}
+		canvas_resume_dsp(dspstate);
+
 		if (changed) canvas_dirty(h->ph_canvas, 1);
 
 		SETFLOAT(ap+0, f);
-- 
GitLab