Skip to content

Commit

Permalink
Fix subtle bug.
Browse files Browse the repository at this point in the history
If one created a new project and then immediately deleted any tags and
applied the changes there would be an error which is now fixed.
  • Loading branch information
prabhuramachandran committed Mar 13, 2017
1 parent 2544b72 commit 067d87c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 7 additions & 1 deletion vixen/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ def update_tags(self, new_tags):
for tag in old_tags:
if tag.name not in new_tag_names:
removed.append(tag)
self.tags = new_tags

for tag in removed:
del self._tag_data[tag.name]
Expand All @@ -240,6 +239,13 @@ def update_tags(self, new_tags):
for tag in added:
self._tag_data[tag.name] = [tag.default]*n_entries

# The above can be the first time when self._tag_data is accessed, when
# creating a new project for example. In this case,
# self.__tag_data_default is called, so if self.tags is set then the
# removed tags will not exist in _tag_data causing an error. So we only
# set self.tags below.
self.tags = new_tags

# Update the cached media
for m in self._media.values():
for tag in removed:
Expand Down
6 changes: 4 additions & 2 deletions vixen/vixen.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Vixen(HasTraits):

def save(self):
data = [dict(name=p.name, save_file=p.save_file)
for p in self.projects]
for p in self.projects if p.name != '__hidden__']
with open(self.save_file, 'w') as fp:
json.dump(data, fp)

Expand Down Expand Up @@ -522,9 +522,11 @@ def process(self, project):
self.info("Remember to save the project once processing completes.")

def remove(self, project):
logger.info('Removing project: %s', project.name)
name = project.name
logger.info('Removing project: %s', name)
self.vixen.remove(project)
self.editor.project = None
self.info('Removed project: %s' % name)

def add_project(self):
name = 'Project%d' % (len(self.vixen.projects))
Expand Down

0 comments on commit 067d87c

Please sign in to comment.