Skip to content

Commit

Permalink
Fix resetting cached all_cells in Player/solver. v2.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
oprypin committed Dec 26, 2014
1 parent b09a670 commit ec3472d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion common.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from __future__ import division, print_function

__version__ = '2.1'
__version__ = '2.1.1'

import sys
import os.path
Expand Down
14 changes: 6 additions & 8 deletions player.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ def drawForeground(self, g, rect):
poly = poly.intersected(QPolygonF(rect))
g.drawConvexPolygon(poly)


@cached_property
def all_cells(self):
return list(self.all(Cell))
Expand All @@ -217,6 +216,11 @@ def all_cells(self):
def all_columns(self):
return list(self.all(Column))

def reset_cache(self):
for attr in ['all_cells', 'all_columns']:
try:
delattr(self, attr)
except AttributeError: pass

def solve_step(self):
"""Derive everything that can be concluded from the current state.
Expand Down Expand Up @@ -431,20 +435,14 @@ def save_geometry_qt(self):
def restore_geometry_qt(self, value):
self.restoreGeometry(QByteArray.fromBase64(value.encode('ascii')))

def reset_cache(self):
for attr in ['all_cells', 'all_columns']:
try:
delattr(self, attr)
except AttributeError: pass

def close_file(self):
self.current_file = None
self.scene.clear()
self.scene.remaining = 0
self.scene.mistakes = 0
self.scene.reset_cache()
for it in [self.title_label, self.author_align_label, self.author_label, self.information_label]:
it.hide()
self.reset_cache()
self.copy_action.setEnabled(False)
return True

Expand Down

0 comments on commit ec3472d

Please sign in to comment.