Author: bugman Date: Tue Feb 3 16:30:52 2015 New Revision: 27479 URL: http://svn.gna.org/viewcvs/relax?rev=27479&view=rev Log: Changes for how the main GUI windows are destroyed by the GUI test tearDown() method.
These changes revert some of the code of previous commits. The recently introduced pipe editor and results viewer windows Delete() methods have been deleted. Instead the Close() methods are called in the tearDown() method to unregister the windows from the observer objects, followed by a wx.Yield() call to flush the wx events, and then the clean_up_windows() GUI test base method is called within a wx.CallAfter() call. This avoids the racing induced segfaults in the GUI tests. Modified: trunk/gui/pipe_editor.py trunk/gui/results_viewer.py trunk/test_suite/gui_tests/base_classes.py Modified: trunk/gui/pipe_editor.py URL: http://svn.gna.org/viewcvs/relax/trunk/gui/pipe_editor.py?rev=27479&r1=27478&r2=27479&view=diff ============================================================================== --- trunk/gui/pipe_editor.py (original) +++ trunk/gui/pipe_editor.py Tue Feb 3 16:30:52 2015 @@ -104,20 +104,6 @@ self.update_grid() - def Destroy(self, event=None): - """Cleanly destroy the window. - - @param event: The wx event. - @type event: wx event - """ - - # Unregister the methods from the observers to avoid unnecessary updating. - self.observer_setup(register=False) - - # Call the parent Destroy() method. - super(Pipe_editor, self).Destroy() - - def activate(self): """Activate or deactivate certain elements in response to the execution lock.""" Modified: trunk/gui/results_viewer.py URL: http://svn.gna.org/viewcvs/relax/trunk/gui/results_viewer.py?rev=27479&r1=27478&r2=27479&view=diff ============================================================================== --- trunk/gui/results_viewer.py (original) +++ trunk/gui/results_viewer.py Tue Feb 3 16:30:52 2015 @@ -106,8 +106,108 @@ self.name = 'results viewer' - def Destroy(self, event=None): - """Cleanly destroy the window. + def Show(self, show=True): + """Change the behaviour of showing the window to update the content. + + @keyword show: A flag which is True shows the window. + @type show: bool + """ + + # Register a few methods in the observer objects. + status.observers.gui_uf.register(self.name, self.refresh, method_name='refresh') + status.observers.pipe_alteration.register(self.name, self.refresh, method_name='refresh') + status.observers.result_file.register(self.name, self.refresh, method_name='refresh') + status.observers.exec_lock.register(self.name, self.activate, method_name='activate') + + # First update. + self.refresh() + + # Activate or deactivate the frame. + self.activate() + + # Show the window using the base class method. + if status.show_gui: + super(Results_viewer, self).Show(show) + + + def activate(self): + """Activate or deactivate certain elements in response to the execution lock.""" + + # Flag for enabling or disabling the elements. + enable = False + if not status.exec_lock.locked(): + enable = True + + # The pipe selector. + wx.CallAfter(self.pipe_name.Enable, enable) + + # The open button. + wx.CallAfter(self.button_open.Enable, enable) + + + def add_files(self, box): + """Create the list of results files. + + @param box: The box sizer to pack the box into. + @type box: wx.BoxSizer instance + @return: The list box element. + @rtype: wx.ListBox element + """ + + # Initialise the list box. + self.file_list = wx.ListCtrl(self.main_panel, -1, style=wx.BORDER_SUNKEN|wx.LC_REPORT) + + # Properties. + self.file_list.SetFont(font.normal) + + # Store the base heights. + self.height_char = self.file_list.GetCharHeight() + + # The headers. + self.file_list.InsertColumn(0, "File type") + self.file_list.InsertColumn(1, "File path") + + # Add to the sizer. + box.Add(self.file_list, 1, wx.ALL|wx.EXPAND, 0) + + # Bind events. + self.file_list.Bind(wx.EVT_SIZE, self.resize) + self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.open_result_file, self.file_list) + + + def build_pipe_sel(self, box): + """Create the data pipe selection element. + + @param box: The horizontal box element to pack the elements into. + @type box: wx.BoxSizer instance + """ + + # Use a horizontal packing of elements. + sizer = wx.BoxSizer(wx.HORIZONTAL) + + # The text. + label = wx.StaticText(self.main_panel, -1, "Data pipe selection") + + # The font and label properties. + label.SetFont(font.subtitle) + + # Add the label to the box. + sizer.Add(label, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) + + # Add a spacer. + sizer.AddSpacer(self.border) + + # A combo box. + self.pipe_name = wx.ComboBox(self.main_panel, -1, value='', style=wx.CB_DROPDOWN|wx.CB_READONLY, choices=[]) + self.pipe_name.SetMinSize((50, 27)) + sizer.Add(self.pipe_name, 1, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) + + # Add the pipe sizer to the main sizer. + box.Add(sizer, 0, wx.ALL|wx.EXPAND, 0) + + + def handler_close(self, event): + """Event handler for the close window action. @param event: The wx event. @type event: wx event @@ -119,123 +219,6 @@ status.observers.result_file.unregister(self.name) status.observers.exec_lock.unregister(self.name) - # Call the parent Destroy() method. - super(Results_viewer, self).Destroy() - - - def Show(self, show=True): - """Change the behaviour of showing the window to update the content. - - @keyword show: A flag which is True shows the window. - @type show: bool - """ - - # Register a few methods in the observer objects. - status.observers.gui_uf.register(self.name, self.refresh, method_name='refresh') - status.observers.pipe_alteration.register(self.name, self.refresh, method_name='refresh') - status.observers.result_file.register(self.name, self.refresh, method_name='refresh') - status.observers.exec_lock.register(self.name, self.activate, method_name='activate') - - # First update. - self.refresh() - - # Activate or deactivate the frame. - self.activate() - - # Show the window using the base class method. - if status.show_gui: - super(Results_viewer, self).Show(show) - - - def activate(self): - """Activate or deactivate certain elements in response to the execution lock.""" - - # Flag for enabling or disabling the elements. - enable = False - if not status.exec_lock.locked(): - enable = True - - # The pipe selector. - wx.CallAfter(self.pipe_name.Enable, enable) - - # The open button. - wx.CallAfter(self.button_open.Enable, enable) - - - def add_files(self, box): - """Create the list of results files. - - @param box: The box sizer to pack the box into. - @type box: wx.BoxSizer instance - @return: The list box element. - @rtype: wx.ListBox element - """ - - # Initialise the list box. - self.file_list = wx.ListCtrl(self.main_panel, -1, style=wx.BORDER_SUNKEN|wx.LC_REPORT) - - # Properties. - self.file_list.SetFont(font.normal) - - # Store the base heights. - self.height_char = self.file_list.GetCharHeight() - - # The headers. - self.file_list.InsertColumn(0, "File type") - self.file_list.InsertColumn(1, "File path") - - # Add to the sizer. - box.Add(self.file_list, 1, wx.ALL|wx.EXPAND, 0) - - # Bind events. - self.file_list.Bind(wx.EVT_SIZE, self.resize) - self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.open_result_file, self.file_list) - - - def build_pipe_sel(self, box): - """Create the data pipe selection element. - - @param box: The horizontal box element to pack the elements into. - @type box: wx.BoxSizer instance - """ - - # Use a horizontal packing of elements. - sizer = wx.BoxSizer(wx.HORIZONTAL) - - # The text. - label = wx.StaticText(self.main_panel, -1, "Data pipe selection") - - # The font and label properties. - label.SetFont(font.subtitle) - - # Add the label to the box. - sizer.Add(label, 0, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) - - # Add a spacer. - sizer.AddSpacer(self.border) - - # A combo box. - self.pipe_name = wx.ComboBox(self.main_panel, -1, value='', style=wx.CB_DROPDOWN|wx.CB_READONLY, choices=[]) - self.pipe_name.SetMinSize((50, 27)) - sizer.Add(self.pipe_name, 1, wx.ALIGN_CENTER_VERTICAL|wx.ADJUST_MINSIZE, 0) - - # Add the pipe sizer to the main sizer. - box.Add(sizer, 0, wx.ALL|wx.EXPAND, 0) - - - def handler_close(self, event): - """Event handler for the close window action. - - @param event: The wx event. - @type event: wx event - """ - - # Unregister the methods from the observers to avoid unnecessary updating. - status.observers.gui_uf.unregister(self.name) - status.observers.pipe_alteration.unregister(self.name) - status.observers.result_file.unregister(self.name) - status.observers.exec_lock.unregister(self.name) - # Close the window. self.Hide() Modified: trunk/test_suite/gui_tests/base_classes.py URL: http://svn.gna.org/viewcvs/relax/trunk/test_suite/gui_tests/base_classes.py?rev=27479&r1=27478&r2=27479&view=diff ============================================================================== --- trunk/test_suite/gui_tests/base_classes.py (original) +++ trunk/test_suite/gui_tests/base_classes.py Tue Feb 3 16:30:52 2015 @@ -173,14 +173,9 @@ del self.app.gui.pipe_editor # Kill the results viewer window. - #if hasattr(self.app.gui, 'results_viewer'): - # self.app.gui.results_viewer.Destroy() - # del self.app.gui.results_viewer - - # Kill the prompt window. - if hasattr(self.app.gui, 'relax_prompt'): - self.app.gui.relax_prompt.Destroy() - del self.app.gui.relax_prompt + if hasattr(self.app.gui, 'results_viewer'): + self.app.gui.results_viewer.Destroy() + del self.app.gui.results_viewer def new_analysis_wizard(self, analysis_type=None, analysis_name=None, pipe_name=None, pipe_bundle=None): @@ -290,6 +285,13 @@ # Get the wx app. self.app = wx.GetApp() + # Close all windows to unregister the observer objects. + if hasattr(self.app.gui, 'pipe_editor'): + self.app.gui.pipe_editor.Close() + if hasattr(self.app.gui, 'results_viewer'): + self.app.gui.results_viewer.Close() + wx.Yield() + # Kill all windows. wx.CallAfter(self.clean_up_windows) _______________________________________________ relax (http://www.nmr-relax.com) This is the relax-commits mailing list relax-commits@gna.org To unsubscribe from this list, get a password reminder, or change your subscription options, visit the list information page at https://mail.gna.org/listinfo/relax-commits