# HG changeset patch # User Jason Maltzen # Date 2015-12-23 23:52:36 # Node ID 78ecf5feebe4f59916bb18e88917640cc28b1b17 # Parent fd647ce690fe3ae4f807fa7914ba985df0e199c2 Fix a crash with potential multi-threaded access to paint recipes. diff --git a/PaintRecipe.cs b/PaintRecipe.cs --- a/PaintRecipe.cs +++ b/PaintRecipe.cs @@ -58,6 +58,21 @@ namespace DesertPaintLab { } + public PaintRecipe(PaintRecipe other) + { + this.dirty = true; + this.reactions = other.reactions; + foreach (string reagentName in other.reagents) + { + this.reagents.Add(reagentName); + } + foreach (RecipeIngredient copyIngredient in other.recipe) + { + RecipeIngredient ingredient = new RecipeIngredient(copyIngredient.name, copyIngredient.quantity); + this.recipe.Add(ingredient); + } + } + public List Ingredients { get { diff --git a/RecipeGeneratorWindow.cs b/RecipeGeneratorWindow.cs --- a/RecipeGeneratorWindow.cs +++ b/RecipeGeneratorWindow.cs @@ -200,6 +200,7 @@ namespace DesertPaintLab protected void OnNewRecipe(object sender, NewRecipeEventArgs args) { + PaintRecipe recipe = new PaintRecipe(args.Recipe); // copy it Gtk.Application.Invoke(delegate { progressBar.Pulse(); @@ -226,7 +227,7 @@ namespace DesertPaintLab colorStore.AppendValues(args.Color); // , missingReactionLabel); countLabel.Text = String.Format("{0} / {1}", generator.Recipes.Count, Palette.Count); } - profile.SetRecipe(args.Recipe); + profile.SetRecipe(recipe); }); }