[Toaster] [PATCH 19/25] toaster: do not create duplicate HelpText objects
Ed Bartosh
ed.bartosh at linux.intel.com
Tue Oct 27 10:28:16 PDT 2015
buildinfohelper code expects only one HelpText object per
build/variable/description.
Current code creates more than one such an object, which causes
toastergui to crash with this exception:
MultipleObjectsReturned: get() returned more than one HelpText -- it returned 2!
Used git_or_create API to ensure that only one HelpText object is
created.
Signed-off-by: Ed Bartosh <ed.bartosh at linux.intel.com>
---
bitbake/lib/bb/ui/buildinfohelper.py | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/bitbake/lib/bb/ui/buildinfohelper.py b/bitbake/lib/bb/ui/buildinfohelper.py
index 04f4184..2803d03 100644
--- a/bitbake/lib/bb/ui/buildinfohelper.py
+++ b/bitbake/lib/bb/ui/buildinfohelper.py
@@ -700,7 +700,6 @@ class ORMWrapper(object):
def save_build_variables(self, build_obj, vardump):
assert isinstance(build_obj, Build)
- helptext_objects = []
for k in vardump:
desc = vardump[k]['doc']
if desc is None:
@@ -711,10 +710,9 @@ class ORMWrapper(object):
if desc is None:
desc = ''
if len(desc):
- helptext_objects.append(HelpText(build=build_obj,
- area=HelpText.VARIABLE,
- key=k,
- text=desc))
+ HelpText.objects.get_or_create(build=build_obj,
+ area=HelpText.VARIABLE,
+ key=k, text=desc)
if not bool(vardump[k]['func']):
value = vardump[k]['v']
if value is None:
@@ -734,8 +732,6 @@ class ORMWrapper(object):
if len(varhist_objects):
VariableHistory.objects.bulk_create(varhist_objects)
- HelpText.objects.bulk_create(helptext_objects)
-
class MockEvent(object):
""" This object is used to create event, for which normal event-processing methods can
--
2.1.4
More information about the toaster
mailing list