From fd224d678198d036432d5bf38839ddfd0ef18630 Mon Sep 17 00:00:00 2001 From: Ebag333 Date: Thu, 8 Dec 2016 16:59:26 -0800 Subject: [PATCH] Don't use try for fittingView, and don't show remove item for modes. --- gui/builtinViews/fittingView.py | 9 +++++---- gui/contextMenu.py | 11 +++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/gui/builtinViews/fittingView.py b/gui/builtinViews/fittingView.py index c047d9844..847d79204 100644 --- a/gui/builtinViews/fittingView.py +++ b/gui/builtinViews/fittingView.py @@ -492,10 +492,11 @@ class FittingView(d.Display): while sel != -1 and sel not in self.blanks: mod = self.mods[self.GetItemData(sel)] - # Test if mod.isEmpty exists. - try: - mod.isEmpty - except AttributeError: + # Test if mod.isEmpty does not exist. + # Certain special module can be missing this trait + # Example: T3D modes + if not hasattr(mod, 'isEmpty'): + # Set it if missing, prevents later stack traces. mod.isEmpty = False if not mod.isEmpty: diff --git a/gui/contextMenu.py b/gui/contextMenu.py index 61823ff3a..dcf5e6764 100644 --- a/gui/contextMenu.py +++ b/gui/contextMenu.py @@ -69,6 +69,17 @@ class ContextMenu(object): if m.display(srcContext, selection): amount += 1 texts = m.getText(itemContext, selection) + + # Check the selected item to see if it has special reasons for not showing the menu item + skip_menu_item = False + for sel in selection: + if hasattr(sel, "_Mode__item") and texts == "Remove Module": + # Don't show remove for modes, these are special modules that cannot be removed + skip_menu_item = True + + if skip_menu_item == True: + continue + if isinstance(texts, basestring): texts = (texts,)