Skip to content

Commit

Permalink
Defend against problems with clearing squeeze buttons, thonny#1528
Browse files Browse the repository at this point in the history
  • Loading branch information
aivarannamaa committed Jan 10, 2021
1 parent 8e6e597 commit db86a51
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions thonny/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -1466,16 +1466,18 @@ def _discard_old_content(self):
def _clear_content(self, cut_idx):
proposed_cut_float = float(cut_idx)
for btn in list(self._squeeze_buttons):
idx = self.index(btn)
if idx is None or float(idx) < proposed_cut_float:
self._squeeze_buttons.remove(btn)
# looks like the widgets are not fully GC-d.
# At least avoid leaking big chunks of texts
try:
try:
idx = self.index(btn)
if idx is None or idx == "" or float(idx) < proposed_cut_float:
self._squeeze_buttons.remove(btn)
# looks like the widgets are not fully GC-d.
# At least avoid leaking big chunks of texts
btn.contained_text = None
btn.destroy()
except:
logger.warning("Could not destroy a squeeze button")
except Exception as e:
logger.warning("Problem with a squeeze button, removing it", exc_info=e)
if btn in self._squeeze_buttons:
self._squeeze_buttons.remove(btn)

self.direct_delete("0.1", cut_idx)

Expand Down

0 comments on commit db86a51

Please sign in to comment.