[bug-gnutrition] Error report (app freezes when adding multiple ingredients to recipe) and patch proposal

jrbruce@vt.edu jrbruce86@gmail.com
Mon May 20 20:18:14 BST 2013


Thanks for adding me to the listserve! I have been looking for a free
app like this one for quite some, so would be happy to help improve it
in any way I can.

I noticed a small bug which was causing me issues whenever I tried to
add more than 3 items to a recipe. Basically what would happen was
that, in recipe_win.py during the 3rd call to the add_ingredient
function, line 326 would end up leading to an infinite while loop and
freezing the app altogether.

I attached a very simple patch which appears to fix this issue. I hope
this helps someone else also!

(Here it is copied and pasted into the message)
diff -cr ./src/recipe_win.py ../gnutrition-0.32_changed/src/recipe_win.py
*** ./src/recipe_win.py    2012-09-01 12:43:08.000000000 -0400
--- ../gnutrition-0.32_changed/src/recipe_win.py    2013-05-20
14:56:23.575795964 -0400
***************
*** 320,329 ****

      def add_ingredient(self, ingr):
          match = 0
-         ret = True
          iter1 = self.ui.treemodel.get_iter_root()
          if self.num_ingr > 0:
!             while ret:
                  try:
                      ingr_in_recipe = self.ui.treemodel.get_value(iter1, 3)
                  except TypeError:
--- 320,328 ----

      def add_ingredient(self, ingr):
          match = 0
          iter1 = self.ui.treemodel.get_iter_root()
          if self.num_ingr > 0:
!             while True:
                  try:
                      ingr_in_recipe = self.ui.treemodel.get_value(iter1, 3)
                  except TypeError:
***************
*** 331,337 ****
                  if ingr_in_recipe.food_num == ingr.food_num:
                      match = 1
                      break
!                 ret = self.ui.treemodel.iter_next(iter1)

          if match == 0:
              iter2 = self.ui.treemodel.append()
--- 330,336 ----
                  if ingr_in_recipe.food_num == ingr.food_num:
                      match = 1
                      break
!                 iter1 = self.ui.treemodel.iter_next(iter1)

          if match == 0:
              iter2 = self.ui.treemodel.append()
Only in ../gnutrition-0.32_changed/src: recipe_win.py~
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: application/octet-stream
Size: 1528 bytes
Desc: not available
URL: <http://www.ocelot.cascaded.net/pipermail/gnutrition/attachments/20130520/562c743d/attachment.bin>


More information about the GNUtrition mailing list