# HG changeset patch # User laurent # Date 1342566306 -7200 # Node ID 52d3a084d2b2bfeacee4781808b311dc4a500938 # Parent b1b1a8f85e2ff8ea293c03ef64910aa7debcaa22 Adding secure extraction of last edited project path to avoid crash if path is not well formatted diff -r b1b1a8f85e2f -r 52d3a084d2b2 Beremiz.py --- a/Beremiz.py Wed Jul 18 00:44:29 2012 +0200 +++ b/Beremiz.py Wed Jul 18 01:05:06 2012 +0200 @@ -440,8 +440,11 @@ projectOpen = DecodeFileSystemPath(projectOpen, False) if ctr is None and projectOpen is None and self.Config.HasEntry("currenteditedproject"): - projectOpen = DecodeFileSystemPath(self.Config.Read("currenteditedproject")) - if projectOpen == "": + try: + projectOpen = DecodeFileSystemPath(self.Config.Read("currenteditedproject")) + if projectOpen == "": + projectOpen = None + except: projectOpen = None if projectOpen is not None and os.path.isdir(projectOpen): @@ -806,10 +809,10 @@ if self.CTR is not None and not self.CheckSaveBeforeClosing(): return - if not self.Config.HasEntry("lastopenedfolder"): + try: + defaultpath = DecodeFileSystemPath(self.Config.Read("lastopenedfolder")) + except: defaultpath = os.path.expanduser("~") - else: - defaultpath = DecodeFileSystemPath(self.Config.Read("lastopenedfolder")) dialog = wx.DirDialog(self , _("Choose a project"), defaultpath, wx.DD_NEW_DIR_BUTTON) if dialog.ShowModal() == wx.ID_OK: @@ -841,10 +844,10 @@ if self.CTR is not None and not self.CheckSaveBeforeClosing(): return - if not self.Config.HasEntry("lastopenedfolder"): + try: + defaultpath = DecodeFileSystemPath(self.Config.Read("lastopenedfolder")) + except: defaultpath = os.path.expanduser("~") - else: - defaultpath = DecodeFileSystemPath(self.Config.Read("lastopenedfolder")) dialog = wx.DirDialog(self , _("Choose a project"), defaultpath, wx.DD_NEW_DIR_BUTTON) if dialog.ShowModal() == wx.ID_OK: