chiark / gitweb /
Do not crash if a machine has no materials at all
authorYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Wed, 2 Sep 2015 18:23:17 +0000 (14:23 -0400)
committerYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Wed, 2 Sep 2015 18:26:59 +0000 (14:26 -0400)
Cura/gui/simpleMode.py

index b252ad77a38e184a01b7526eb116031473dc0027..288fee4748953b0537c0f5e1938d4b88b1bd7f6d 100644 (file)
@@ -159,7 +159,7 @@ class simpleModePanel(wx.Panel):
                                        if button.profile == selectedMaterial:
                                                button.SetValue(True)
                                                break
-                       self._materialSelected(None)
+               self._materialSelected(None)
                self.Layout()
 
        def _materialTypeSelected(self, e):
@@ -224,6 +224,13 @@ class simpleModePanel(wx.Panel):
                boxsizer.Clear(True)
                self._print_profile_options = []
 
+               if material is None:
+                       self.printOptionsBox.Show(False)
+                       self.printTypePanel.Show(False)
+                       return
+               self.printOptionsBox.Show(True)
+               self.printTypePanel.Show(True)
+
                # Add new profiles
                selectedProfile = None
                for print_profile in material.profiles:
@@ -301,7 +308,9 @@ class simpleModePanel(wx.Panel):
                        self._update(e)
 
        def _update(self, e):
-               profile.putProfileSetting('simpleModeMaterial', self._getSelectedMaterial().name)
+               material = self._getSelectedMaterial()
+               if material:
+                       profile.putProfileSetting('simpleModeMaterial', material.name)
                for button in self._print_profile_options:
                        if button.GetValue():
                                profile.putProfileSetting('simpleModeProfile', button.profile.name)
@@ -314,7 +323,9 @@ class simpleModePanel(wx.Panel):
                                settings[setting.getName()] = setting.getDefault()
 
                # Apply materials, profile, then options
-               settings.update(self._getSelectedMaterial().getProfileDict())
+               material = self._getSelectedMaterial()
+               if material:
+                       settings.update(material.getProfileDict())
                for button in self._print_profile_options:
                        if button.GetValue():
                                settings.update(button.profile.getProfileDict())