Commit 3ce2c6a1 authored by eric pellegrini's avatar eric pellegrini

Bug fix due to PyDeadObjectError when destroying a widow without

unsubing the listener
parent 0accd864
......@@ -274,6 +274,7 @@ class MolecularViewerPanel(ComponentPlugin):
self.clear_universe()
pub.unsubscribe(self.msg_set_selection, "msg_set_selection")
pub.unsubscribe(self.msg_switch_viewers_state, "msg_switch_viewers_state")
pub.unsubscribe(self.msg_clear_selection,'msg_clear_selection')
......
......@@ -34,7 +34,7 @@ import wx
from MDANSE import ELEMENTS
from MDANSE.Framework.Configurable import ConfigurationError
from MDANSE.Framework.Configurators.IConfigurator import ConfiguratorError
from MDANSE.Framework.UserDefinitionStore import UD_STORE
from MDANSE.Framework.Widgets.AtomSelectionWidget import AtomSelectionWidget
from MDANSE.GUI.Icons import ICONS
......@@ -86,7 +86,7 @@ class AtomTransmutationWidget(AtomSelectionWidget):
element = children[2].GetStringSelection()
if not element:
raise ConfigurationError("No target element provided for %r selection." % udName)
raise ConfiguratorError("No target element provided for %r selection." % udName)
uds.append([udName,element])
......
......@@ -59,6 +59,8 @@ class IWidget(wx.Panel):
self.build_panel()
self.Bind(wx.EVT_WINDOW_DESTROY,self.OnDestroy)
pub.subscribe(self._set_data, 'msg_set_data')
@property
......@@ -109,3 +111,8 @@ class IWidget(wx.Panel):
return
self.set_data(plugin.datakey)
def OnDestroy(self,event):
pub.unsubscribe(self._set_data, 'msg_set_data')
event.Skip()
\ No newline at end of file
......@@ -57,6 +57,12 @@ class McStasParametersWidget(IWidget):
return self._sizer
def OnDestroy(self,event):
pub.unsubscribe(self.msg_set_instrument, "msg_set_instrument")
IWidget.OnDestroy(self, event)
def msg_set_instrument(self, message):
widget, parameters = message
......
......@@ -87,7 +87,12 @@ class UserDefinitionWidget(IWidget):
self.Bind(wx.EVT_BUTTON, self.on_new_definition, newUD)
return sizer
def OnDestroy(self,event):
pub.unsubscribe(self.msg_set_ud, 'msg_set_ud')
IWidget.OnDestroy(self,event)
def on_view_definition(self,event):
viewUD = event.GetEventObject()
......
......@@ -55,6 +55,8 @@ class DataTreePanel(wx.Panel):
self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.on_double_click_data)
self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.on_drag_data)
self.Bind(wx.EVT_TREE_KEY_DOWN, self.on_delete_data, self._tree)
self.Bind(wx.EVT_WINDOW_DESTROY,self.OnDestroy)
pub.subscribe(self.msg_load_input_data, 'msg_load_input_data')
pub.subscribe(self.msg_delete_input_data, 'msg_delete_input_data')
......@@ -63,6 +65,12 @@ class DataTreePanel(wx.Panel):
def tree(self):
return self._tree
def OnDestroy(self,event):
pub.unsubscribe(self.msg_load_input_data, 'msg_load_input_data')
pub.unsubscribe(self.msg_delete_input_data, 'msg_delete_input_data')
event.Skip()
def msg_load_input_data(self, data):
if data is None:
......
......@@ -188,6 +188,8 @@ class JobControllerPanel(wx.ScrolledWindow):
EVT_JOB_CONTROLLER(self,self.on_update)
self.Bind(wx.EVT_WINDOW_DESTROY,self.OnDestroy)
pub.subscribe(self.msg_start_job,"msg_start_job")
def __del__(self):
......@@ -196,6 +198,12 @@ class JobControllerPanel(wx.ScrolledWindow):
while self._jobsController.is_alive():
time.sleep(0.01)
def OnDestroy(self,event):
pub.subscribe(self.msg_start_job,"msg_start_job")
event.Skip()
def msg_start_job(self,message):
self._jobsController.update()
......
......@@ -60,12 +60,19 @@ class PluginsTreePanel(wx.Panel):
self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.on_drag, self._tree)
self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.on_double_click)
pub.subscribe(self.msg_set_plugins_tree, 'msg_set_plugins_tree')
pub.subscribe(self.msg_set_plugins_tree, 'msg_set_plugins_tree')
self.Bind(wx.EVT_WINDOW_DESTROY,self.OnDestroy)
@property
def tree(self):
return self._tree
def OnDestroy(self,event):
pub.subscribe(self.msg_set_plugins_tree, 'msg_set_plugins_tree')
event.Skip()
def build_panel(self):
self._tree = wx.TreeCtrl(self, wx.ID_ANY, style=wx.TR_DEFAULT_STYLE|wx.TR_HIDE_ROOT)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment