[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gnutrition] Error report (app freezes when adding multiple ingr
From: |
address@hidden |
Subject: |
Re: [bug-gnutrition] Error report (app freezes when adding multiple ingredients to recipe) and patch proposal |
Date: |
Wed, 22 May 2013 15:07:47 -0400 |
You're welcome!
I found another two bugs that I'd like to bring up. I put all of my
patches so far into a single .diff file attached, and this includes
fixes for the following two newer bugs I came across also.
1. I'm not sure why I didn't encounter this before, but in person.py
there is a small typo (num_portions is mispelled wum_portions). This
randomly started causing the app to crash on startup, but fixing the
typo seemed to resolve the issue.
2. In lines 230 and 233 of plan_win.py, the "+ ':00'" was causing the
iter_for_time() to not return the right position and iterator. and
this would make it impossible to add a recipe to the plan.
Here is the patch (it is also attached to the email). If you wnat just
the patch for the two errors let me know (this is a patch for all the
bug fixes I've made on my computer so far):
diff -rc ./src/database.py ../gnutrition-0.32_changed/src/database.py
*** ./src/database.py 2012-09-01 12:43:08.000000000 -0400
--- ../gnutrition-0.32_changed/src/database.py 2013-05-21
00:09:35.968388136 -0400
***************
*** 176,185 ****
# create ingredient table
self.create_table("CREATE TABLE ingredient " +
! "(recipe_no INTEGER PRIMARY KEY NOT NULL, " +
"amount REAL NOT NULL, " +
"Msre_Desc TEXT NOT NULL, " +
! "NDB_No INTEGER NOT NULL)", 'ingredient')
# create recipe category table
self.create_load_table("CREATE TABLE category " +
--- 176,185 ----
# create ingredient table
self.create_table("CREATE TABLE ingredient " +
! "(recipe_no INTEGER NOT NULL, " +
"amount REAL NOT NULL, " +
"Msre_Desc TEXT NOT NULL, " +
! "NDB_No INTEGER PRIMARY KEY NOT NULL)", 'ingredient')
# create recipe category table
self.create_load_table("CREATE TABLE category " +
Only in ../gnutrition-0.32_changed/src: database.py~
diff -rc ./src/person.py ../gnutrition-0.32_changed/src/person.py
*** ./src/person.py 2012-09-01 12:43:08.000000000 -0400
--- ../gnutrition-0.32_changed/src/person.py 2013-05-22
14:48:54.177184979 -0400
***************
*** 91,97 ****
result = self.db.get_result()
if result and len(result) != 0:
! for person_num, date, time, wum_portions, recipe_num in result:
self.db.query("INSERT INTO recipe_plan_temp VALUES" +
" ('%d', '%s', '%s', '%f', '%d' )"
% (person_num, str(date), str(time), num_portions,
--- 91,97 ----
result = self.db.get_result()
if result and len(result) != 0:
! for person_num, date, time, num_portions, recipe_num in result:
self.db.query("INSERT INTO recipe_plan_temp VALUES" +
" ('%d', '%s', '%s', '%f', '%d' )"
% (person_num, str(date), str(time), num_portions,
Only in ../gnutrition-0.32_changed/src: person.py~
diff -rc ./src/plan_win.py ../gnutrition-0.32_changed/src/plan_win.py
*** ./src/plan_win.py 2012-09-01 12:43:08.000000000 -0400
--- ../gnutrition-0.32_changed/src/plan_win.py 2013-05-22
14:50:04.809535227 -0400
***************
*** 221,229 ****
value_list = string.split(value, ':')
if int(value_list[0]) < 10:
#time_string2 = '0' + value + ':00'
! time_string2 = value + ':00'
else:
! time_string2 = value + ':00'
if time_string1 == time_string2:
return iter, pos
pos = pos + 1
--- 221,229 ----
value_list = string.split(value, ':')
if int(value_list[0]) < 10:
#time_string2 = '0' + value + ':00'
! time_string2 = value# + ':00'
else:
! time_string2 = value# + ':00'
if time_string1 == time_string2:
return iter, pos
pos = pos + 1
Only in ../gnutrition-0.32_changed/src: plan_win.py~
diff -rc ./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~
On Wed, May 22, 2013 at 10:57 AM, Jason Self <address@hidden> wrote:
> address@hidden <address@hidden> wrote ..
>> 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.
>
> Sure - Any and all help is welcome.
>
>> 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!
>
> Thank you very much!
>
> _______________________________________________
> https://lists.gnu.org/mailman/listinfo/bug-gnutrition
patch.diff
Description: Binary data
- [bug-gnutrition] Error report (app freezes when adding multiple ingredients to recipe) and patch proposal, address@hidden, 2013/05/20
- Re: [bug-gnutrition] Error report (app freezes when adding multiple ingredients to recipe) and patch proposal, Jason Self, 2013/05/22
- Re: [bug-gnutrition] Error report (app freezes when adding multiple ingredients to recipe) and patch proposal,
address@hidden <=
- Re: [bug-gnutrition] Error report (app freezes when adding multiple ingredients to recipe) and patch proposal, Jason Self, 2013/05/23
- Re: [bug-gnutrition] Error report (app freezes when adding multiple ingredients to recipe) and patch proposal, address@hidden, 2013/05/23
- Re: [bug-gnutrition] Error report (app freezes when adding multiple ingredients to recipe) and patch proposal, address@hidden, 2013/05/29
- Re: [bug-gnutrition] Error report (app freezes when adding multiple ingredients to recipe) and patch proposal, address@hidden, 2013/05/29
- Re: [bug-gnutrition] Error report (app freezes when adding multiple ingredients to recipe) and patch proposal, address@hidden, 2013/05/29