# HG changeset patch # User laurent # Date 1335484545 -7200 # Node ID d751b1c609b3f645c2de19ea6a7b901aeb0ee321 # Parent 47b9ad1471ccc706ab45da7b04a32e0210bf9fe3 Fix bug when closing project and one editor is opened diff -r 47b9ad1471cc -r d751b1c609b3 RessourceEditor.py --- a/RessourceEditor.py Mon Apr 23 11:16:40 2012 +0200 +++ b/RessourceEditor.py Fri Apr 27 01:55:45 2012 +0200 @@ -406,13 +406,14 @@ setattr(self.InstancesGrid, "_MoveRow", _MoveInstance) def _RefreshInstanceButtons(): - rows = self.InstancesTable.GetNumberRows() - row = self.InstancesGrid.GetGridCursorRow() - self.DeleteInstanceButton.Enable(rows > 0) - self.UpInstanceButton.Enable(row > 0 and - self.InstancesTable.GetValueByName(row, "Task") == self.InstancesTable.GetValueByName(row - 1, "Task")) - self.DownInstanceButton.Enable(0 <= row < rows - 1 and - self.InstancesTable.GetValueByName(row, "Task") == self.InstancesTable.GetValueByName(row + 1, "Task")) + if self: + rows = self.InstancesTable.GetNumberRows() + row = self.InstancesGrid.GetGridCursorRow() + self.DeleteInstanceButton.Enable(rows > 0) + self.UpInstanceButton.Enable(row > 0 and + self.InstancesTable.GetValueByName(row, "Task") == self.InstancesTable.GetValueByName(row - 1, "Task")) + self.DownInstanceButton.Enable(0 <= row < rows - 1 and + self.InstancesTable.GetValueByName(row, "Task") == self.InstancesTable.GetValueByName(row + 1, "Task")) setattr(self.InstancesGrid, "RefreshButtons", _RefreshInstanceButtons) self.InstancesGrid.SetRowLabelSize(0) diff -r 47b9ad1471cc -r d751b1c609b3 controls/CustomGrid.py --- a/controls/CustomGrid.py Mon Apr 23 11:16:40 2012 +0200 +++ b/controls/CustomGrid.py Fri Apr 27 01:55:45 2012 +0200 @@ -72,16 +72,17 @@ button.Bind(wx.EVT_BUTTON, getattr(self, "On%sButton" % name)) def RefreshButtons(self): - rows = self.Table.GetNumberRows() - row = self.GetGridCursorRow() - if self.AddButton is not None: - self.AddButton.Enable(self.Editable) - if self.DeleteButton is not None: - self.DeleteButton.Enable(self.Editable and rows > 0) - if self.UpButton is not None: - self.UpButton.Enable(self.Editable and row > 0) - if self.DownButton is not None: - self.DownButton.Enable(self.Editable and 0 <= row < rows - 1) + if self: + rows = self.Table.GetNumberRows() + row = self.GetGridCursorRow() + if self.AddButton is not None: + self.AddButton.Enable(self.Editable) + if self.DeleteButton is not None: + self.DeleteButton.Enable(self.Editable and rows > 0) + if self.UpButton is not None: + self.UpButton.Enable(self.Editable and row > 0) + if self.DownButton is not None: + self.DownButton.Enable(self.Editable and 0 <= row < rows - 1) def CloseEditControl(self): row, col = self.GetGridCursorRow(), self.GetGridCursorCol() diff -r 47b9ad1471cc -r d751b1c609b3 controls/VariablePanel.py --- a/controls/VariablePanel.py Mon Apr 23 11:16:40 2012 +0200 +++ b/controls/VariablePanel.py Fri Apr 27 01:55:45 2012 +0200 @@ -551,19 +551,20 @@ setattr(self.VariablesGrid, "_MoveRow", _MoveVariable) def _RefreshButtons(): - table_length = len(self.Table.data) - row_class = None - row_edit = True - row = 0 - if table_length > 0: - row = self.VariablesGrid.GetGridCursorRow() - row_edit = self.Table.GetValueByName(row, "Edit") - if self.PouIsUsed: - row_class = self.Table.GetValueByName(row, "Class") - self.AddButton.Enable(not self.Debug and (not self.PouIsUsed or self.Filter not in ["Interface", "Input", "Output", "InOut"])) - self.DeleteButton.Enable(not self.Debug and (table_length > 0 and row_edit and row_class not in ["Input", "Output", "InOut"])) - self.UpButton.Enable(not self.Debug and (table_length > 0 and row > 0 and self.Filter == "All" and row_class not in ["Input", "Output", "InOut"])) - self.DownButton.Enable(not self.Debug and (table_length > 0 and row < table_length - 1 and self.Filter == "All" and row_class not in ["Input", "Output", "InOut"])) + if self: + table_length = len(self.Table.data) + row_class = None + row_edit = True + row = 0 + if table_length > 0: + row = self.VariablesGrid.GetGridCursorRow() + row_edit = self.Table.GetValueByName(row, "Edit") + if self.PouIsUsed: + row_class = self.Table.GetValueByName(row, "Class") + self.AddButton.Enable(not self.Debug and (not self.PouIsUsed or self.Filter not in ["Interface", "Input", "Output", "InOut"])) + self.DeleteButton.Enable(not self.Debug and (table_length > 0 and row_edit and row_class not in ["Input", "Output", "InOut"])) + self.UpButton.Enable(not self.Debug and (table_length > 0 and row > 0 and self.Filter == "All" and row_class not in ["Input", "Output", "InOut"])) + self.DownButton.Enable(not self.Debug and (table_length > 0 and row < table_length - 1 and self.Filter == "All" and row_class not in ["Input", "Output", "InOut"])) setattr(self.VariablesGrid, "RefreshButtons", _RefreshButtons) self.VariablesGrid.SetRowLabelSize(0)