From: Youness Alaoui Date: Wed, 28 Oct 2015 18:33:07 +0000 (-0400) Subject: Better fix for T35 X-Git-Tag: lulzbot-17.12~7 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=ee3e19b8afe79b5ba48f76cf7bb9fc415a748bb7;p=cura.git Better fix for T35 Reverts previous commit and fixes it properly. The issue wasn't that wx would send a setting change event after the control was destroyed, but rather, it would send a setting change event on the list box just before the destroy event. The issue was that OnSettingChange would reset the config for all of the controls, instead of only for the control that changed, and so it was trying to access already destroyed controls. --- diff --git a/Cura/gui/pluginPanel.py b/Cura/gui/pluginPanel.py index a2ef07bf..75be91df 100644 --- a/Cura/gui/pluginPanel.py +++ b/Cura/gui/pluginPanel.py @@ -125,7 +125,6 @@ class pluginPanel(wx.Panel): s.Add(ctrl, pos=(3+i,2), span=(1,2), flag=wx.EXPAND|wx.LEFT|wx.RIGHT,border=3) ctrl.Bind(wx.EVT_TEXT, self.OnSettingChange) - ctrl.Bind(wx.EVT_WINDOW_DESTROY, self.OnCtrlDestroyed) pluginPanel.paramCtrls[param['name']] = ctrl i += 1 @@ -144,23 +143,15 @@ class pluginPanel(wx.Panel): self.panelList.append(pluginPanel) return True - # This is needed because on wx 2.8, a SettingChange event - # is sent right after the ctrl gets destroyed which causes a PyDeadCode exception - def OnCtrlDestroyed(self, e): - ctrl = e.GetWindow() - for panel in self.panelList: - for k in panel.paramCtrls.keys(): - if panel.paramCtrls[k] == ctrl: - del panel.paramCtrls[k] - def OnSettingChange(self, e): for panel in self.panelList: idx = self.panelList.index(panel) for k in panel.paramCtrls.keys(): - if type(panel.paramCtrls[k].GetValue()) == bool: - self.pluginConfig[idx]['params'][k] = int(panel.paramCtrls[k].GetValue()) - else: - self.pluginConfig[idx]['params'][k] = panel.paramCtrls[k].GetValue() + if panel.paramCtrls[k] == e.GetEventObject(): + if type(panel.paramCtrls[k].GetValue()) == bool: + self.pluginConfig[idx]['params'][k] = int(panel.paramCtrls[k].GetValue()) + else: + self.pluginConfig[idx]['params'][k] = panel.paramCtrls[k].GetValue() pluginInfo.setPostProcessPluginConfig(self.pluginConfig) self.callback()