# HG changeset patch # User laurent # Date 1346103417 -7200 # Node ID abf1afc1f04dee42c5bea4628d6b006230602f64 # Parent c0f60c2a5a24616acfba127dab5e7a9170705508 Fix bug when closing IECCodeView and IECRawCodeView, reopening them was impossible diff -r c0f60c2a5a24 -r abf1afc1f04d ProjectController.py --- a/ProjectController.py Mon Aug 27 22:13:43 2012 +0200 +++ b/ProjectController.py Mon Aug 27 23:36:57 2012 +0200 @@ -14,7 +14,7 @@ import targets import connectors -from util.misc import CheckPathPerm, GetClassImporter +from util.misc import CheckPathPerm, GetClassImporter, IECCodeViewer from util.MiniTextControler import MiniTextControler from util.ProcessLogger import ProcessLogger from util.FileManagementPanel import FileManagementPanel @@ -948,8 +948,7 @@ if self._IECCodeView is None: plc_file = self._getIECcodepath() - self._IECCodeView = TextViewer(self.AppFrame.TabsOpened, "", None, None, instancepath=name) - #self._IECCodeView.Enable(False) + self._IECCodeView = IECCodeViewer(self.AppFrame.TabsOpened, "", None, None, instancepath=name) self._IECCodeView.SetTextSyntax("ALL") self._IECCodeView.SetKeywords(IEC_KEYWORDS) try: @@ -958,6 +957,7 @@ text = '(* No IEC code have been generated at that time ! *)' self._IECCodeView.SetText(text = text) self._IECCodeView.SetIcon(GetBitmap("ST")) + setattr(self._IECCodeView, "_OnClose", self.OnCloseEditor) if self._IECCodeView is not None: self.AppFrame.EditProjectElement(self._IECCodeView, name) @@ -966,14 +966,14 @@ elif name == "IEC raw code": if self._IECRawCodeView is None: - controler = MiniTextControler(self._getIECrawcodepath()) + controler = MiniTextControler(self._getIECrawcodepath(), self) - self._IECRawCodeView = TextViewer(self.AppFrame.TabsOpened, "", None, controler, instancepath=name) - #self._IECRawCodeView.Enable(False) + self._IECRawCodeView = IECCodeViewer(self.AppFrame.TabsOpened, "", None, controler, instancepath=name) self._IECRawCodeView.SetTextSyntax("ALL") self._IECRawCodeView.SetKeywords(IEC_KEYWORDS) self._IECRawCodeView.RefreshView() self._IECRawCodeView.SetIcon(GetBitmap("ST")) + setattr(self._IECRawCodeView, "_OnClose", self.OnCloseEditor) if self._IECRawCodeView is not None: self.AppFrame.EditProjectElement(self._IECRawCodeView, name) diff -r c0f60c2a5a24 -r abf1afc1f04d util/MiniTextControler.py --- a/util/MiniTextControler.py Mon Aug 27 22:13:43 2012 +0200 +++ b/util/MiniTextControler.py Mon Aug 27 23:36:57 2012 +0200 @@ -6,8 +6,12 @@ class MiniTextControler: - def __init__(self, filepath): + def __init__(self, filepath, controller): self.FilePath = filepath + self.BaseController = controller + + def __del__(self): + self.BaseController = None def CTNFullName(self): return "" @@ -31,14 +35,17 @@ def GetEditedElementType(self, tagname, debug = False): return "program" + def GetBlockType(self, type, inputs = None, debug = False): + return self.BaseController.GetBlockType(type, inputs, debug) + def GetBlockTypes(self, tagname = "", debug = False): - return [] + return self.BaseController.GetBlockTypes(tagname, debug) def GetDataTypes(self, tagname = "", basetypes = True, only_locatables = False, debug = False): - return [] + return self.BaseController.GetDataTypes(tagname, basetypes, only_locatables, debug) def GetEnumeratedDataValues(self, debug = False): - return [] + return self.BaseController.GetEnumeratedDataValues(debug) def StartBuffering(self): pass diff -r c0f60c2a5a24 -r abf1afc1f04d util/misc.py --- a/util/misc.py Mon Aug 27 22:13:43 2012 +0200 +++ b/util/misc.py Mon Aug 27 23:36:57 2012 +0200 @@ -3,7 +3,9 @@ """ import os,sys - + +from TextViewer import TextViewer + # helper func to check path write permission def CheckPathPerm(path): if path is None or not os.path.isdir(path): @@ -23,3 +25,9 @@ else: return classpath +class IECCodeViewer(TextViewer): + + def __del__(self): + TextViewer.__del__(self) + if getattr(self, "_OnClose"): + self._OnClose(self) \ No newline at end of file