enthought / traitsui

TraitsUI: Traits-capable windowing framework
http://docs.enthought.com/traitsui
Other
296 stars 95 forks source link

Window restoration broken on wx #944

Open ievacerny opened 4 years ago

ievacerny commented 4 years ago

Modifying the issue to be more broad than one editor as it affects quite a few demos, including the demo app itself. It is impossible to launch the same wx application more than once because of the bug in window restoration code. This is seen using wx 4.0 and wx 4.1 on MacOS.

Original description

First time Standard_Editors/DataFrameEditor_demo.py launches and works as expected. Trying to launch the demo again right after closing fails with the following error:

Traceback (most recent call last):
  File "/Users/icernyte/Documents/repos/traitsui/traitsui/wx/view_application.py", line 152, in OnInit
    args=self.args,
  File "/Users/icernyte/Documents/repos/traitsui/traitsui/view.py", line 462, in ui
    ui.ui(parent, kind)
  File "/Users/icernyte/Documents/repos/traitsui/traitsui/ui.py", line 246, in ui
    self.rebuild(self, parent)
  File "/Users/icernyte/Documents/repos/traitsui/traitsui/wx/toolkit.py", line 125, in ui_live
    ui_live.ui_live(ui, parent)
  File "/Users/icernyte/Documents/repos/traitsui/traitsui/wx/ui_live.py", line 52, in ui_live
    _ui_dialog(ui, parent, BaseDialog.NONMODAL)
  File "/Users/icernyte/Documents/repos/traitsui/traitsui/wx/ui_live.py", line 88, in _ui_dialog
    BaseDialog.display_ui(ui, parent, style)
  File "/Users/icernyte/Documents/repos/traitsui/traitsui/wx/ui_base.py", line 86, in display_ui
    restore_window(ui, is_popup=(style in BaseDialog.POPUP_TYPES))
  File "/Users/icernyte/Documents/repos/traitsui/traitsui/wx/helper.py", line 150, in restore_window
    x, y, dx, dy = prefs
ValueError: not enough values to unpack (expected 4, got 2)
ievacerny commented 4 years ago

Same issue affects demos in Standard_Editors/File_Dialog

rahulporuri commented 4 years ago

I'm seeing the same issue when I try closing a clean application (without any local stored state). If I try closing the application, I get tracebacks on the command line and I see a clean/empty application - which i have to then close again

PS C:\Users\rporuri> edm run -e ets-demo-app-wx -- etsdemo
Traceback (most recent call last):
  File "C:\Users\rporuri\.edm\envs\ets-demo-app-wx\lib\site-packages\traitsui\wx\view_application.py", line 152, in OnInit
    args=self.args,
  File "C:\Users\rporuri\.edm\envs\ets-demo-app-wx\lib\site-packages\traitsui\view.py", line 462, in ui
    ui.ui(parent, kind)
  File "C:\Users\rporuri\.edm\envs\ets-demo-app-wx\lib\site-packages\traitsui\ui.py", line 244, in ui
    self.rebuild(self, parent)
  File "C:\Users\rporuri\.edm\envs\ets-demo-app-wx\lib\site-packages\traitsui\wx\toolkit.py", line 125, in ui_live
  File "C:\Users\rporuri\.edm\envs\ets-demo-app-wx\lib\site-packages\traitsui\wx\ui_live.py", line 52, in ui_live
    _ui_dialog(ui, parent, BaseDialog.NONMODAL)
  File "C:\Users\rporuri\.edm\envs\ets-demo-app-wx\lib\site-packages\traitsui\wx\ui_live.py", line 88, in _ui_dialog
    BaseDialog.display_ui(ui, parent, style)
  File "C:\Users\rporuri\.edm\envs\ets-demo-app-wx\lib\site-packages\traitsui\wx\ui_base.py", line 86, in display_ui
    restore_window(ui, is_popup=(style in BaseDialog.POPUP_TYPES))
  File "C:\Users\rporuri\.edm\envs\ets-demo-app-wx\lib\site-packages\traitsui\wx\helper.py", line 150, in restore_window
    x, y, dx, dy = prefs
ValueError: not enough values to unpack (expected 4, got 2)
OnInit returned false, exiting...
wx._core.wxAssertionError: C++ assertion "GetEventHandler() == this" failed at ..\..\src\common\wincmn.cpp(475) in wxWindowBase::~wxWindowBase(): any pushed event handlers must have been removed

The above exception was the direct cause of the following exception:

SystemError: <class 'property'> returned a result with an error set
wx._core.wxAssertionError: C++ assertion "GetEventHandler() == this" failed at ..\..\src\common\wincmn.cpp(475) in wxWindowBase::~wxWindowBase(): any pushed event handlers must have been removed

The above exception was the direct cause of the following exception:

SystemError: <class 'property'> returned a result with an error set
Error in atexit._run_exitfuncs:
wx._core.wxAssertionError: C++ assertion "GetEventHandler() == this" failed at ..\..\src\common\wincmn.cpp(475) in wxWindowBase::~wxWindowBase(): any pushed event handlers must have been removed
PS C:\Users\rporuri>
PS C:\Users\rporuri> edm run -e ets-demo-app-wx -- etsdemo
11:52:58: Warning: iCCP: known incorrect sRGB profile
Traceback (most recent call last):
  File "C:\Users\rporuri\.edm\envs\ets-demo-app-wx\lib\site-packages\traitsui\wx\ui_live.py", line 318, in _on_close_page
    self._on_cancel(event)
  File "C:\Users\rporuri\.edm\envs\ets-demo-app-wx\lib\site-packages\traitsui\wx\ui_live.py", line 358, in _on_cancel
    self.close(wx.ID_CANCEL)
  File "C:\Users\rporuri\.edm\envs\ets-demo-app-wx\lib\site-packages\traitsui\wx\ui_live.py", line 311, in close
    ui.finish()
  File "C:\Users\rporuri\.edm\envs\ets-demo-app-wx\lib\site-packages\traitsui\ui.py", line 278, in finish
    self.reset(destroy=False)
  File "C:\Users\rporuri\.edm\envs\ets-demo-app-wx\lib\site-packages\traitsui\ui.py", line 316, in reset
    editor.dispose()
  File "C:\Users\rporuri\.edm\envs\ets-demo-app-wx\lib\site-packages\traitsui\wx\tree_editor.py", line 292, in dispose
    self._delete_node(nid)
  File "C:\Users\rporuri\.edm\envs\ets-demo-app-wx\lib\site-packages\traitsui\wx\tree_editor.py", line 513, in _delete_node
    self._tree.Delete(nid)
wx._core.wxAssertionError: C++ assertion ""tvItem->hItem != ((HTREEITEM)(ULONG_PTR)-0x10000)"" failed at ..\..\src\msw\treectrl.cpp(880) in wxTreeCtrl::DoGetItem(): can't retrieve virtual root item
wx._core.wxAssertionError: C++ assertion "GetEventHandler() == this" failed at ..\..\src\common\wincmn.cpp(475) in wxWindowBase::~wxWindowBase(): any pushed event handlers must have been removed

The above exception was the direct cause of the following exception:

SystemError: <class 'wx._core.WindowDestroyEvent'> returned a result with an error set
Event loop failed to close cleanly:
Traceback (most recent call last):
  File "C:\Users\rporuri\.edm\envs\ets-demo-app-wx\lib\site-packages\traitsui\wx\view_application.py", line 139, in __init__
    start_event_loop_wx(self)
  File "C:\Users\rporuri\.edm\envs\ets-demo-app-wx\lib\site-packages\pyface\util\guisupport.py", line 115, in start_event_loop_wx
    app.MainLoop()
  File "C:\Users\rporuri\.edm\envs\ets-demo-app-wx\lib\site-packages\wx\core.py", line 2224, in MainLoop
    rv = wx.PyApp.MainLoop(self)
wx._core.wxAssertionError: C++ assertion "GetEventHandler() == this" failed at ..\..\src\common\wincmn.cpp(475) in wxWindowBase::~wxWindowBase(): any pushed event handlers must have been removed