Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wxSplitterWindow idle event handler for Python #729

Open
tester0077 opened this issue Feb 18, 2022 · 5 comments
Open

wxSplitterWindow idle event handler for Python #729

tester0077 opened this issue Feb 18, 2022 · 5 comments

Comments

@tester0077
Copy link

tester0077 commented Feb 18, 2022

The current event handler code for the splitter causes a crash when exiting a python app using the code from wxFB which includes a splitter.
As I am very new to (wx)Python, I have no idea if or how this can be fixed. Any help or comments will be much appreciated.

The generated code:

def m_splitter2OnIdle( self, event ):
        self.m_splitter2.SetSashPosition( 0 )
        self.m_splitter2.Unbind( wx.EVT_IDLE )

with the error

d:\pkg\python\wxFB\wxPython\wpMeta\wpMeta.py' 
Traceback (most recent call last):
  File "d:\pkg\python\wxFB\wxPython\wpMeta\wpMetaBase.py", line 170, in m_splitter2OnIdle
    self.m_splitter2.SetSashPosition( 0 )
RuntimeError: wrapped C/C++ object of type SplitterWindow has been deleted
Traceback (most recent call last):
  File "d:\pkg\python\wxFB\wxPython\wpMeta\wpMetaBase.py", line 170, in m_splitter2OnIdle
    self.m_splitter2.SetSashPosition( 0 )
RuntimeError: wrapped C/C++ object of type SplitterWindow has been deleted
Traceback (most recent call last):
  File "d:\pkg\python\wxFB\wxPython\wpMeta\wpMetaBase.py", line 170, in m_splitter2OnIdle
    self.m_splitter2.SetSashPosition( 0 )
RuntimeError: wrapped C/C++ object of type SplitterWindow has been deleted
Traceback (most recent call last):
  File "d:\pkg\python\wxFB\wxPython\wpMeta\wpMetaBase.py", line 170, in m_splitter2OnIdle
    self.m_splitter2.SetSashPosition( 0 )
RuntimeError: wrapped C/C++ object of type SplitterWindow has been deleted
Traceback (most recent call last):
  File "d:\pkg\python\wxFB\wxPython\wpMeta\wpMetaBase.py", line 170, in m_splitter2OnIdle
    self.m_splitter2.SetSashPosition( 0 )
RuntimeError: wrapped C/C++ object of type SplitterWindow has been deleted
@sodevel
Copy link
Member

sodevel commented Feb 19, 2022

I don't know any Python at all or how the wxWidgets language binding does work, so i can only guess here. This event handler should be called only once during idle time, apparently it gets called too late, after the C++ side got cleaned up. Or maybe too early, when the C++ side isn't initialized yet? Do you initialize wxWidgets properly? To you create or delete your Python objects at the wrong time? In C++ e.g. you cannot use most wxWidgets components as static class members because the will get used before wxWidgets is initialized, maybe some problem like this exists in Python as well.

@tester0077
Copy link
Author

After looking at the code some more, it looks like it ought to unbind itself after the first call, and yet it seems to get called 5 times in a row. Seems like the unbind is never actually executed.
Unfortunately, after running into this issue, I removed the code in my current app to avoid the crash.
I have just added another splitter and the splitterxOnIdle is called very time the mouse enters the main frame, which confirms my suspicion, but at this stage and with my current understanding of Python and wxFormBuilder, I am unable to debug it into the unbind call.

@tester0077
Copy link
Author

Eventually, I recalled from, my work long ago, when I was using wxFB for my C++ projects, that it adds its own OnIdle handler, which it immediately removed. Hence for C++ I had to add my own OnIdle handler if I wanted this feature to work with my own needs. As

@tester0077
Copy link
Author

tester0077 commented Feb 21, 2022

@tester0077
Copy link
Author

I have now raised the issue on the wxPython forum, because it looks to me as though the problem is with wxPython not unbinding the handler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants