From db3855635750a3bc95d18ac5fe15b63455bd6b5c Mon Sep 17 00:00:00 2001 From: David Vierra Date: Mon, 13 Mar 2017 16:54:58 -1000 Subject: [PATCH] Fix #291 - FillCommandWidget cached globally instead of per-session --- src/mcedit2/editorcommands/fill.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/mcedit2/editorcommands/fill.py b/src/mcedit2/editorcommands/fill.py index 8632f3c..e488bf8 100644 --- a/src/mcedit2/editorcommands/fill.py +++ b/src/mcedit2/editorcommands/fill.py @@ -18,15 +18,13 @@ class FillCommandWidget(QtGui.QDialog, Ui_fillDialog): self.blockTypeInput.editorSession = editorSession self.blockTypeInput.block = "minecraft:stone" -_fillWidget = None - -# xxxx why? +# Cache the FillCommandWidget on the session. Gross. def getFillWidget(editorSession): - global _fillWidget - if _fillWidget is None: - _fillWidget = FillCommandWidget(editorSession) - _fillWidget.editorSession = editorSession - return _fillWidget + widget = getattr(editorSession, '_fillWidget', None) + + if widget is None: + widget = editorSession._fillWidget = FillCommandWidget(editorSession) + return widget def fillCommand(editorSession):