bug-gnutrition
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-gnutrition] Error report (app freezes when adding multiple ingredie


From: address@hidden
Subject: [bug-gnutrition] Error report (app freezes when adding multiple ingredients to recipe) and patch proposal
Date: Mon, 20 May 2013 15:18:14 -0400

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~

Attachment: patch.diff
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]